Go back to Knowledge Base
In some cases, it could be interesting to search and delete files older than a certain number of hours or days. These files could be logs, backup or anything else.
To do this, you need to write a batch file with the following command:
forfiles /p F:\Backup /s /m *.bak /d -3 /c "cmd /c del /q @file"
This command will look for any file named *.bak and older than 3 days, then delete it.
I hope this will help you to write easy scripts to maintain your systems.
Go back to Knowledge Base
- Details
-
Written by Nicolas Buache
-
Created on Saturday, 14 January 2012
-
Last Updated on Saturday, 14 January 2012
-
Hits: 554