October 28, 2008 at 10:16 am
I have following ActiveX script to delete files older than one day from folder C:\Test
_____________________________________________________________
Dim fso,fol,f
set fso = CreateObject("Scripting.FileSystemObject")
Set fol = fso.GetFolder("C:\Test\")
For each f in fol.Files
if datediff("d",f.DateLastModified,now()) > 1 and _
right (f.path,4) =".txt" then
fso.DeleteFile f.Path
End if
next
_________________________________________
I want to modify it in a such way that it will delete files from C:\Test\ and all subfolders under that.
means ( C:\Test\One , C:\Test\Two )
October 28, 2008 at 10:47 am
My VBScript skills are a little weak, but something like this should work:
Dim fso,fol,f
set fso = CreateObject("Scripting.FileSystemObject")
Set fol = fso.GetFolder("C:\Test\")
For each f in fol.Folders
DeleteFiles(f)
next
DeleteFiles(fol)
Sub DeleteFiles(Fol)
Dim f
For each f in fol.Files
if datediff("d",f.DateLastModified,now()) > 1 and _
right (f.path,4) =".txt" then
fso.DeleteFile f.Path
End if
next
End Sub
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
October 28, 2008 at 11:37 am
no, not working
October 28, 2008 at 11:47 am
Could you be more specific? Are there any errors? Is is not deleting files?
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
October 28, 2008 at 4:17 pm
error on line 6
object doesn't support property called "Folders"
October 28, 2008 at 4:31 pm
bang725 (10/28/2008)
error on line 6object doesn't support property called "Folders"
Did you attempt to determine what might be the correct property to find folders within a folder? Maybe .Subfolders? Have you looked up the fso Folder object anywhere?
As I said my VBScript skills are a bit weak and rusty since I have not used it in awhile.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
October 28, 2008 at 4:35 pm
I *think* you need to replace fol.Folders with fol.SubFolders.
October 29, 2008 at 9:02 am
thanks!!!
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply