troubleshooting Question

Batch script to delete certain files in tree

Avatar of sneeuw
sneeuwFlag for Belgium asked on
Microsoft DOS
25 Comments1 Solution3208 ViewsLast Modified:
Hi,

On my Win98 machine I always ran this batch script to delete a bunch of temporary files in the directory from where the bacth was run and its sub-directories.

It doesn't seem to work using NT (2K, XP)

Question, can somebody suggest a solution ?
Preferably a solution that works well on Win98 ranging to WinXP but if that is not possible then no problem.
I have to ditch 98 sooner or later anyway.

This is the batch I have been using all these years :

echo off

rem del __del.lst
rem del __dell.lst
rem del __dell.bat

del deleted.lst

dir *.~?? /s/b >> __dell.lst
dir *.~? /s/b >> __dell.lst
dir *.il? /s/b >> __dell.lst
dir *.obj /s/b >> __dell.lst

copy __dell.lst deleted.lst

:: http://www.ericphelps.com/batch/samples/vxe2exe.bat.txt
::
:: Make a line fragment
:: See http://www.ericphelps.com/batch/lines/frag-dbg.htm

echo e 100 "del " > script
echo e 104 22 >> script
echo rcx>> script
echo 5>> script
echo n __del.lst>> script
echo w>> script
echo q>>script
debug < script > nul
del script

:: Now process each line
:LOOPSTART
    rem *** Check to see if __dell.lst is zero bytes
    dir __dell.lst | find "__dell.lst" | find " 0 " > nul
    if not errorlevel 1 goto DONE
    copy /b __del.lst + __dell.lst __dell.bat  > nul
    rem *** Create a new __dell.lst minus the first line
    type __dell.bat | find /v "del " > __dell.lst
    rem *** Trim the bat file so it only has the first line
    type __dell.bat | find "del " > __dell.bat
    rem *** Display :
    type __dell.bat
    rem *** Execute :
    call __dell.bat
goto LOOPSTART    
:DONE


del __del.lst
del __dell.lst
del __dell.bat
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 25 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 25 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros