是否有可能为一个批处理文件,删除文件,如果从文本文件列表没有发现? [英] Is it possible for a batch file to delete a file if not found in list from text file?
本文介绍了是否有可能为一个批处理文件,删除文件,如果从文本文件列表没有发现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试写会遍历目录,如果该文件的第一部分中的所有文件的文本文件中找不到然后删除一个批处理文件。
在图像目录中的文件命名,如:
1_a.jpg
1_b.jpg
1_c.jpg
2_a.jpg
3_a.jpg
3_b.jpg
的文件中的列表
2
3
所以在这一点上,我想删除
1_a.jpg
1_b.jpg
1_c.jpg
使用入门:
关闭@echo
wget的-N http://www.domain.com/imagelist.txt
FOR / R C:\\图像目录\\ %% G IN(* .JPG)DO ??????? %%G
和IM卡住了。
解决方案
关闭@echo
SETLOCAL
集文件夹=C:\\ somePath
设置excludeFile =C:\\ somePath2 \\ someFile.txt
FOR / FEOL =:delims =%% f由于('DIR / B / A-D%文件夹%^ | FINDSTR / vibg:%excludeFile%')做删除%文件夹%\\ %% F
Trying to write a batch file that will loop through all the files in a directory and if the first part of the file is not found in the text file then delete.
In the images directory the files are named like:
1_a.jpg
1_b.jpg
1_c.jpg
2_a.jpg
3_a.jpg
3_b.jpg
in the file the list is
2
3
So at this point I would like to delete
1_a.jpg
1_b.jpg
1_c.jpg
Started by using:
@echo off
wget -N http://www.domain.com/imagelist.txt
FOR /R C:\image-directory\ %%G IN (*.jpg) DO ??????? %%G
And im stuck.
解决方案
@echo off
setlocal
set folder="c:\somePath"
set excludeFile="c:\somePath2\someFile.txt"
for /f "eol=: delims=" %%F in ('dir /b /a-d %folder% ^| findstr /vibg:%excludeFile%') do del "%folder%\%%F"
这篇关于是否有可能为一个批处理文件,删除文件,如果从文本文件列表没有发现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文