简体   繁体   中英

Batch Delete Files From File On Cmd Line

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?

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"

这应该工作:

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

如果您安装Cygwin或类似的东西,它只是:

cat files.log | xargs rm

对于cmd,批处理文件%a中必须包含%% a而不是%a

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM