简体   繁体   English

批处理文件在文件夹中经过一定时间后删除文件?

[英]Batch file to delete files after a certain amount of time in folder?

Is there a way I can create a batch file to delete files from a folder if they are in there for a certain number of days. 有没有一种方法可以创建一个批处理文件,以从文件夹中删除文件(如果它们存在一定天数)。

For example: 例如:

A files is in folder "edited" and has been there for a month, and if a file is in there for a month of longer, the batch file deletes it. 文件位于“已编辑”文件夹中,并且已存在一个月,如果文件已存在一个月以上,则批处理文件将删除该文件。

I'm guessing I would create a batch file then have it run on a schedule to check for files that have been there too long, I just don't know how to write the batch file. 我猜我会创建一个批处理文件,然后让它按计划运行以检查已经存在太长时间的文件,我只是不知道如何编写该批处理文件。

Thanks in advance! 提前致谢!

Googled a little, seems this is the solution: 谷歌一点,似乎这是解决方案:

forfiles -p "c:\your\folder" -s -m *.* /D -<number of days> /C "cmd /c del @path"

Change “C:\\your\\folder” to the directory to which you are saving the files you want to delete on a schedule. 将“ C:\\ your \\ folder”更改为要将计划删除的文件保存到的目录。 Note that the -40 refers to the day after which all files should be deleted so change the -40 if required. 请注意,-40是指应删除所有文件的第二天,因此如果需要,请更改-40。

Have a look at this post Batch file to delete files older than N days 查看此帖子批处理文件以删除N天之前的文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 批处理文件删除文件和文件夹 - Batch file to delete files and folder 带有提示选项的要关闭的批处理文件将其中止并在一定时间后重新运行? - A batch file for shutdown with prompt option to abort it and re-run after a certain time of amount? 批处理脚本以删除特定计数值后目录中的文件 - Batch Script To Delete Files Within a Directory After A Certain Count Value 需要批处理文件来一次打开一个文件夹中的所有.XLSM文件(上一个关闭后下一个打开) - Need batch file to open all .XLSM files in a folder one at a time (open next after previous closes) 是否可以使用Windows批处理文件删除某些rar文件? - Is it possible to use a Windows batch file to delete certain rar files? 在批处理文件中,如何删除非特定类型的所有文件 - In a batch file, how do I delete all files NOT of a certain type 批处理-删除文件夹和所有文件 - Batch - Delete folder and all files 使用批处理删除文件夹中除列表中的文件以外的所有文件 - Delete all files in folder except file in list using batch Windows批处理命令用于从一个文件夹中删除文件 - Windows batch command to delete files from a folder except one file 删除文件夹B中与文件夹A批处理文件中的文件具有相同前缀的文件 - Delete Files in Folder B that have the same Prefix as files in Folder A Batch File
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM