Reputation: 59
I have to delete tmp files that are older than 6 months. I have this command runing in the batch file which delete files older than 180 days.
forfiles /p "C:\Backup" /s /m *.tmp /c "cmd /c Del @path" /d -180
but I want to pass number of month
instead of number of days
. any idea would be greatly helpful. Thanks in advance
Upvotes: 5
Views: 5335
Reputation: 171
You could also use powershell commands if you really want to provide day, month, year any of these as an argument.
Example:
Get-ChildItem –Path “C:\Backups” –Recurse | Where-Object CreationTime –lt (Get-Date).AddMonths(-6) | Remove-Item
Upvotes: 2
Reputation: 4805
AFAIK for forfiles
you cant pass months as an argument either you have to pass the Date
or No of Days
..
see this document for more info https://technet.microsoft.com/en-us/library/cc753551.aspx
but instead you can read the value as months and convert it to days and pass it forfiles
manually..
How are you passing days to forfile in your batchfile now?
Upvotes: 1