I have a folder named backup
in D:
drive, under that folder there is a daily backup getting created for a day with folder names as the date of the backup.
I only want to keep the backup data for yesterday, (i.e. the latest one) and delete the old ones on daily basis automatically.
The problem I'm facing is, the data under the latest folder also is getting deleted.
Could you please help me with a script which only removes the old folders except the one recently modified or modified yesterday, in such a way that it doesn't delete any data from the recent folder.
Here is the code I am using:
forfiles -p "D:Test" -s -m *.* /D -1 /C "cmd /c Del @path"