VBScript delete specific folders older than

July 8, 2010 at 10:27:12
Specs: server 2003
I am new to scripting and I am trying to create a script that will delete specific folders (20*) that are older than 3 days. Any help would be appreciated.

See More: VBScript delete specific folders older than

Report •


#1
July 9, 2010 at 20:45:15
'EDITED 7/12/10 line 9
dim fso
wscript.echo date()
set fso=createobject("scripting.filesystemobject")
set folder=fso.getfolder(".")
for each file in folder.files
xx=file.datelastmodified
tt=datediff("d",xx,date())
if tt>3 then
wscript.echo "TO BE DELETED: "&file.name&" "&tt
'safety in ON foll line
'fso.deletefile file.name
end if
next

Report •

#2
July 12, 2010 at 05:26:37
Thank you for your help. I am getting an error on line 9 Char: 14. The error is a Syntax Error code; 800a03ea. the source is a vbscript compilation error. The error looks like it is coming from the word TO. If you have any advice I would greatly appreciate it.

Thank you


Report •

#3
July 12, 2010 at 10:31:56
sorry, i missed a quote. See revised resp#1 edited to fix.
(leading quote missing on line 9)

Report •

Related Solutions

#4
July 12, 2010 at 10:42:01
I greatly appreciate your help. I am still getting the error on line 9 but char: 46 now. There is an Unterminated string constant, code: 800a0409. I did try to put " after "&tt. What would you recommend?

Report •

#5
July 14, 2010 at 13:04:32
daggone! my mistake, apologies. not enough coffee or too much beer...
line 9 should be:
wscript.echo "TO BE DELETED: "&file.name&" "&tt

i'll fix it in the post also.


Report •

#6
August 2, 2010 at 08:00:27
this does not delete folders it deletes files.

Report •

Ask Question