Why ?
To
use a CMD code (.bat) that delete files older than x days and/or use a compact
windows feature ( compact) use the below code as a sample to achieve this goal.
How ?
Below
is a Windows CMD code that will cleanup/delete files and compact other files
based on age, in my below code example I will delete files older than 180 days
and compact(compress) files older than 2 days in specific path with certain file
pattern naming:
1- Code below:
:: Delete All Archives
older than 6 months (1 weeks for client logs)
echo %DATE% %TIME%
forfiles /p
"E:\Avanza\Logs\Svc" /s /m PayHub_*.log /c "cmd /c Del @path"
/d -180
forfiles /p "E:\Avanza\Logs\Svc" /s /m PayHub_*.log /c "cmd /c if @isdir==FALSE Compact /c @path" /d -2
No comments:
Post a Comment