Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Job to delete folders older than X days old ? Expand / Collapse
Author
Message
Posted Thursday, February 6, 2014 1:13 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, October 28, 2014 9:54 AM
Points: 300, Visits: 499
Hi

I wanted to run a job nightly that would delete folders within a folder that where older than 3 days old

for example c:\output has 2 folders (c:\output\folder1 and c:\output\folder2) I don't care whats in them only if folder1 or folder2 is older than 3 days delete the entre folder
just leave c:\output

Thanks in Advance
Joe
Post #1538824
Posted Thursday, February 6, 2014 2:41 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 11:55 AM
Points: 2,832, Visits: 8,519
I run this as a SQL scheduled job on my Windows 2003 server:

ForFiles /P D:\objectscripts /D -180 /C "CMD /C if @ISDIR==TRUE echo RD /Q /S @FILE &RD /Q /S @FILE"

It deletes the folders in D:\objectscripts older than 180 days. Not sure about the syntax, I just found it the other day on someone's website. Test it first in a non critical area.



Post #1538877
Posted Thursday, February 6, 2014 8:56 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 1:58 PM
Points: 17,854, Visits: 15,803
homebrew01 (2/6/2014)
I run this as a SQL scheduled job on my Windows 2003 server:

ForFiles /P D:\objectscripts /D -180 /C "CMD /C if @ISDIR==TRUE echo RD /Q /S @FILE &RD /Q /S @FILE"

It deletes the folders in D:\objectscripts older than 180 days. Not sure about the syntax, I just found it the other day on someone's website. Test it first in a non critical area.


Nice find.




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #1538985
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse