Page 1 of 1

batch delete specific dates

Posted: 11 Feb 2023 03:30
by Bookmaster
Hello,

Each night I have backup files, like multiple folders with files in those folders. Files names in the folders are irrelevant for this question, but every file has a creation date. So basically in each folder, I have multiple files with the same name but different creation dates. Each morning I have to go into every single folder and delete all files apart from those containing yesterday's date. It is not a big job, it takes me about 5 minutes, but I am wondering if there is a way that could a batch script that will do it instead of me, please?

Thanks in advance.

BM

Re: batch delete specific dates

Posted: 15 Feb 2023 07:37
by Bookmaster
I did manage to put something that can be useful as a start:

ForFiles /p f:\iCentar-BackUps\15-02-2023\ /s /d -2 /c "cmd /c del @file"

That is just for folders under the name 15-02-2023 which is also the creation date of that folder. If I want to use this I will have to change creation date every morning to be able to use what I wrote above.
Is there any way that I can automatically have today date instead of 15-02-2023, please?

regards

BM