JonDog
JonDog

Reputation: 555

I need to delete files that meet criteria from all subfolders with a batch file

I am trying to manage some of my backup overflow problems. Currently I have a .bat file that will delete all the files that are > 14 days old. My problem is that I need to loop through all subfolders and delete all .bak files that are > 14 days old as well. Any help would be appreciated.

here what i have so far.

D:
cd D:\DBBK

forfiles -p  D:\DBBK -m *.bak -d -14 -c "cmd /c del @file"

Upvotes: 1

Views: 1061

Answers (1)

JonDog
JonDog

Reputation: 555

ok, so that was easy. i only had to add an "/s" to the forfiles.

D:
cd D:\DBBK

forfiles /s -p  D:\DBBK -m *.bak -d -14 -c "cmd /c del @file"

Upvotes: 3

Related Questions