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. Note that the -40 refers to the day after which all files should be deleted so change the -40 if required.
Have a look at this post Batch file to delete files older than N days
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.