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

时间:2021-12-11 02:28:55

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. Now i want to delete all of those files. I tried del < c:\files.log but that doesn't work. What should I use?

该文件约为3mb。现在我想删除所有这些文件。我尝试了del \>

4 个解决方案

#1


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”

#2


This should work:

这应该工作:

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

#3


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

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

cat files.log | xargs rm

#4


You must have %%a and not %a inside the batch file %a for cmd

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

#1


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”

#2


This should work:

这应该工作:

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

#3


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

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

cat files.log | xargs rm

#4


You must have %%a and not %a inside the batch file %a for cmd

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