Hello,
I want to delete files after a certain period of time after the files are created.
So i am thinking about a batch file that runs all the time and checking wether one or more files in a folder exists longer than a given period (lets say 15 minutes) and then delete the file(s).
Is there anyone who can help me with this?
With kind regards,
Peter
Deleting files after a certain period of time
Moderator: DosItHelp
-
- Expert
- Posts: 1167
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Deleting files after a certain period of time
Anything period of time less than one day means you have to manually calculate the age of the file, which is a hassle. If you want to remove all files over one day old, you can just use something like
Fortunately I've needed a script that does 15 minutes before, but it's not on this computer so I'll post it when I have it. If somebody with "Expert" under their name posts code before I do, go with theirs.
Code: Select all
forfiles /p <path> /C "cmd /c del @path" /d -<time>
Fortunately I've needed a script that does 15 minutes before, but it's not on this computer so I'll post it when I have it. If somebody with "Expert" under their name posts code before I do, go with theirs.
Re: Deleting files after a certain period of time
XXcopy has finer granularity and can use the /L switch to just list the files, which can be processed in a for /F loop.
www.xxcopy.com
www.xxcopy.com