[THIN] Re: Script to delete files/folders older than x days

  • From: Dan Dill <DanD@xxxxxxxxxx>
  • To: "thin@xxxxxxxxxxxxx" <thin@xxxxxxxxxxxxx>
  • Date: Mon, 19 Mar 2012 17:48:34 -0700

I wrote this to flush out cookies older than x days, it's in vbscript and a 
little dated but should be easy to simplify or modify as needed: 
http://danstechnotes.blogspot.com/2008/04/delete-cookies-script.html

Not nearly as simple as the forfiles command though...

If you have servers that have powershell I would highly recommend using 
powershell for this...

Here's a line in a powershell script I use to delete files older than 38 days 
in a given folder:

dir c:\path *.* | where-object {-not $_.PSIsContainer -and ($_.lastWriteTime 
-le ((get-date).addDays(-38)))} | remove-item -force


Dan Dill |Systems Engineer

From: thin-bounce@xxxxxxxxxxxxx [mailto:thin-bounce@xxxxxxxxxxxxx] On Behalf Of 
Angela Smith
Sent: Monday, March 19, 2012 1:03 AM
To: thin@xxxxxxxxxxxxx
Subject: [THIN] Script to delete files/folders older than x days

Hi

Im looking at running a script from my Citrix servers via a scheduled task that 
deletes files and folders older than 1 day.  Has anyone used such a script 
before?  I was looking at forfiles but I cant work out the syntax to delete 
files and folders in 1 line.  I run the following which works but I would 
prefer to run it off 1 line as I have many paths to check

FORFILES /P "L:\PATH" /S /M *.* /D -1 /C "cmd /c del "@file" /q" >>D:\Log.txt
FORFILES /P "L:\PATH"  /D -1 /C "CMD /C if @ISDIR==TRUE echo RD /S /Q @FILE &RD 
/S /Q @FILE" >>D:\Log.txt


Any assistance appreciated


Thanks
Ang


Other related posts: