简体   繁体   English

从Cmd行上的文件批量删除文件

[英]Batch Delete Files From File On Cmd Line

I have a long list of file names in a txt file, which I generated using 我在txt文件中有很长的文件名列表,我使用它生成

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

The file is about 3mb. 该文件约为3mb。 Now i want to delete all of those files. 现在我想删除所有这些文件。 I tried del < c:\\files.log but that doesn't work. 我尝试了del <c:\\ files.log,但这不起作用。 What should I use? 我该怎么用?

Batch for NT on up supports a FOR loop with special switches NT on up的批处理支持带有特殊开关的FOR循环

FOR /F seems to fit what you want as it allows input from a file and positional delimiters. FOR / F似乎符合您的要求,因为它允许来自文件和位置分隔符的输入。

See .. http://ss64.com/nt/for_f.html 请参阅.. 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 = *”%% 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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