简体   繁体   English

如何制作在当前文件夹中工作的批处理文件并删除特定文件?

[英]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.

相关问题 批处理:如何制作包含没有扩展名的文件夹中的所有文件的.txt文件 - Batch: How to make a .txt file with all files in a folder without extensions 如何打开特定文件夹以列出其中的文件 - How to open a specific folder to list files within 批处理文件以将文本文件中列出的文件从一个文件夹移动到另一个文件夹 - Batch file to Move files listed in a text file from one folder to another 删除非最新文件的批处理脚本 - Batch script to delete non latest files 如何获取 android 中特定文件夹中的视频文件列表? - How to get list of video files in a specific folder in android? 如何使用 python 中的 file.txt 中的文件名重命名文件夹中的文件? - how to rename files in a folder with the files name in file.txt in python? 如何制作批处理文件中删除的参数列表? - How to make a list of arguments which is dropped on a batch file? 批处理文件以列出文件夹内的子文件夹 - Batch file to list subfolders inside a folder 如何读取存储在给定文件夹中的多个文件并从所有文件中获取特定日期值 -- Python - How to read multiple files stored in a given folder and fetch specific date value form all files -- Python 如何获取包含子文件夹的文件夹中文件的文件路径? - How to get file paths of files inside a folder including subfolders?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM