batch delete specific dates

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Bookmaster
Posts: 3
Joined: 11 Feb 2023 03:13

batch delete specific dates

#1 Post by Bookmaster » 11 Feb 2023 03:30

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

Bookmaster
Posts: 3
Joined: 11 Feb 2023 03:13

Re: batch delete specific dates

#2 Post by Bookmaster » 15 Feb 2023 07:37

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

Post Reply