windows 如何创建按计划删除文件夹的批处理脚本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/615008/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I create a batch script that will delete a folder on a scheduled basis?
提问by user73628
Exact Duplicates:
精确复制:
- How to write a batch file to delete the files which are 5 days or older from a folder?
- write a batch file to delete 6 days older files from a folder
- write a batch file to delete 5 daya older files from a folder
- How do I write a batch file to delete folders and files on a time basis?
- write a batch file to remove the folders by date and time wise.
- write a script to delete files from a folder which are 5 days older than current date
- 如何编写批处理文件以从文件夹中删除 5 天或更旧的文件?
- 编写批处理文件以从文件夹中删除 6 天前的文件
- 编写批处理文件以从文件夹中删除 5 天的旧文件
- 如何编写批处理文件以按时间删除文件夹和文件?
- 编写一个批处理文件以按日期和时间删除文件夹。
- 编写脚本从文件夹中删除比当前日期早 5 天的文件
How do I create a batch script that will delete a folder on a scheduled basis?
如何创建按计划删除文件夹的批处理脚本?
回答by Andrew Hare
Write a batch script to delete the file
编写一个批处理脚本来删除文件
rd <YOURDIR>
and then schedule it in Windows Tasks.
然后在 Windows 任务中安排它。
回答by Ishmael
Create a batch to delete the file and then place it on a scheduled task on a server or workstation.
创建批处理以删除文件,然后将其放置在服务器或工作站上的计划任务上。
回答by Eppz
In a text editor do the following
在文本编辑器中执行以下操作
@echo off
rd <enter your directory name here>
Save the file as filename.bat
将文件另存为 filename.bat
Create a scheduled task and select the batch file as the file to run.
创建定时任务,选择批处理文件作为运行文件。
回答by Tiberiu Ana
You write your batch file and then, even better than using the Scheduler manually, you can use the atcommand to schedule the .bat file to run periodically.
您编写批处理文件,然后,甚至比手动使用调度程序更好,您可以使用at命令来安排 .bat 文件定期运行。
The advantage of this is that you can put your final atcommand in a second bat file for easier distribution to your target systems.
这样做的好处是您可以将最终的at命令放在第二个 bat 文件中,以便更容易地分发到您的目标系统。