I've read it several times. There are parts I still don't quite understand.... Even copying the code down and running it doesn't work.
No matter what I do with the part below, I can't get the effect I want... OP, please take another look.
This command can be even more powerful. For example, your todel.txt might not be as clean as in the example above, but generated directly by DIR, with some useless information in it, like this:
Volume in drive D is DATA
Volume Serial Number is C47C-9908
Directory of D:\tmp
09/26/2001 12:50 PM 18,426 alg0925.txt
12/02/2001 04:29 AM 795 bsample.txt
04/11/2002 04:18 AM 2,043 invitation.txt
4 File(s) 25,651 bytes
0 Dir(s) 4,060,700,672 bytes free
for can still extract the filenames from it and operate on them:
for /f "skip=5 tokens=5" %a in (todel.txt) do @if exist %a DEL %a
Of course, the command above performs deletion. If you just want to see which files will be operated on, replace DEL with ech
for /f "skip=5 tokens=5" %a in (todel.txt) do @if exist %a echo %a
You will see:
alg0925.txt
bsample.txt
invitation.txt