views:

718

answers:

3

I have a long list of file names in a txt file, which I generated using

findstr /M "string here" *.* > c:\files.log

The file is about 3mb. Now i want to delete all of those files. I tried del < c:\files.log but that doesn't work. What should I use?

A: 

If you install Cygwin or something similar it's just:

cat files.log | xargs rm
Avdi
+2  A: 

Batch for NT on up supports a FOR loop with special switches

FOR /F seems to fit what you want as it allows input from a file and positional delimiters.

See .. http://ss64.com/nt/for_f.html

You are looking for something like...

for /F "tokens=*" %%a in (files.log) DO DELETE "%%a"

CMB
For bonus points OP could pipe his findstr input into the FOR.
Rob Elliott
Absolutely.... However, segmenting things into a files allows you to inspect/debug batch files.
CMB
Rob: You can't pipe into for. You'd have to use `for /f %x in ('some command')`. But you can't pipe into it :)
Joey
+1  A: 

This should work:

for /f "tokens=1*" %a in (filelist.txt) do del %a
Ken White