[英]How to make a batch file that works in the current folder and delete specific files?
I've been searching around how to make a batch file that works in it's current folder that it was executed.我一直在寻找如何制作一个批处理文件,该文件在它执行的当前文件夹中工作。 Then uses a filelist.txt along with the batch in that same folder to delete the files listed in that filelist.txt
然后使用 filelist.txt 以及同一文件夹中的批处理删除该 filelist.txt 中列出的文件
It boils down like this I run the batch file -> Batch file uses current folder it is in -> Uses filelist.txt the batch file is with -> batch file deletes the files listed in the filelist.txt它归结为这样我运行批处理文件 -> 批处理文件使用它所在的当前文件夹 -> 使用批处理文件所在的 filelist.txt -> 批处理文件删除 filelist.txt 中列出的文件
Help will be greatly appreciated..帮助将不胜感激..
By default, the batch file will run in its current directory.默认情况下,批处理文件将在其当前目录中运行。
What you are asking can be accomplished with one line.你问的可以用一行来完成。
for /f %%i in (filelist.txt) do if exist %%i del %%i
If the files are in different folders you will need to specify the full path for each file in filelist.txt如果文件位于不同的文件夹中,则需要在 filelist.txt 中为每个文件指定完整路径
ex.前任。
C:\\users\\Johndoe\\desktop\\picture1.jpg C:\\用户\\Johndoe\\桌面\\picture1.jpg
C:\\users\\Johndoe\\documents\\picture2.jpg C:\\users\\Johndoe\\documents\\picture2.jpg
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.