SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Job to delete folders older than X days old ?


Job to delete folders older than X days old ?

Author
Message
jbalbo
jbalbo
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1523 Visits: 688
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
homebrew01
homebrew01
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12726 Visits: 9222
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.



SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)

Group: General Forum Members
Points: 68339 Visits: 18570
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

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search