Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

forfiles to delete old files and directories

Status
Not open for further replies.

PTmon

IS-IT--Management
Mar 8, 2001
284
US
Hi,
Our oracle backups get dumped out onto a win2k3 file server every night. A new directory with the date is created, and the backups are inside these directories. I want to remove any files and directories older than 4 days.

It seems like forfiles should be a good answer, and I am able to delete the files, but so far I'm not successful in deleting the directories.

This is what I've got that works for removing the files, the directory removal doesn't happen, and I don't get an error:
Code:
forfiles -p G:\CRISAPelicanDMP\BACKUPSET /S /M * /D -4 /C "cmd /c if @isdir==FALSE del @FILE /S ELSE RD @PATH /S"

Any help is appreciated.
Thanks,
pt


putting the "new" in "newb".....
 
Take a look at my CleanBadMail.vbs script:


I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top