0

I have referred to this page, Batch file to delete files older than N days. and the code works, but only for a predefined no of days.

forfiles /p "C:\what\ever" /s /m *.* /D -<number of days> /C "cmd /c del @path"

But now, I want to initiate a program such that I can find the oldest date from C:\what\ever, then delete the files in that folder and subdirectories, one day at a time, to a pre-defined date, or days. For example, the oldest date is 11/04/2020, I wanna delete from 11/04/2020, then 12/04/2020...all the way to 29/5/2022 or -1 day. (As of typing this, the date is 30/5/2022).

Thank you.

Compo
  • 36,585
  • 5
  • 27
  • 39
  • In what is this different to the um question you linked? – aschipfl May 30 '22 at 05:44
  • I'd be interested to know exactly the reason why you'd want to delete them all, but in a specific order. Within a short fraction of time, they'd all be gone, except for the those within the days period you've set, so why would the order matter? I could understand it if you were performing another task before deleting each, but that is not part of your request. – Compo May 30 '22 at 09:31
  • aschipfl - The question is different as in /D -'any value' is for a set day only once; I am trying to delete by a set day repeatedly, just that the set day is decreasing by 1. Compo - The reason I want to delete them all is because the files are massive, as in more than 8GB; by deleting for a set day, let's say files older than 90 days, the computer may hang. Thank you Mofi for linking the chapter. I will read up on it. – Flora Trace May 31 '22 at 07:09

0 Answers0