0
votes

Using cmd I want to delete all of the files in the directory except specific files for example .txt which are older than 2 days.

im unable to combine between forfiles and deleting everything beside a specific file type.

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

where and how i can add the exception i want ?

Thanks !

1
Please post an MCVE.user10324273

1 Answers

0
votes

I'm not positive about what you're wanting to do, but my best guess is that you just need to tell ForFiles to ignore that particular extension:

… "cmd /c if not @ext==0x22txt0x22 del @path"