rcoast
asked on
Script to delete files after X days
I need a script that will recursively delete all files, based upon a pattern, that are older than X days, from a starting directory.
Thank you!
Thank you!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
rob: well aren't you mister fancy pants :)
Actually, looking at that, the recursion bit is commented out. Change this bit near the bottom:
Next
'If UCase(RecurseOn) = "YES" Then
recurse subfolder, strPartOfFileName
'End If
Next
to this
Next
If UCase(RecurseOn) = "YES" Then
recurse subfolder, strPartOfFileName
End If
Next
so that the recursion flag works.
You will also need to uncomment all of the
file.delete
lines when you actually want to delete them.
I guess I should have added an "output only" flag as well.....
Regards,
Rob.
Next
'If UCase(RecurseOn) = "YES" Then
recurse subfolder, strPartOfFileName
'End If
Next
to this
Next
If UCase(RecurseOn) = "YES" Then
recurse subfolder, strPartOfFileName
End If
Next
so that the recursion flag works.
You will also need to uncomment all of the
file.delete
lines when you actually want to delete them.
I guess I should have added an "output only" flag as well.....
Regards,
Rob.
@ Weelio,
LOL! Thanks, but not really....I just adapted it from another "delete files older than" script, and as I said, I haven't tested it that much.....hopefully it works....give it a whirl.....
P.S. I don't like fancy pants that much either.....I'm not much of a "colourful" guy.....I tend to play it *safe* in the fasion sense......although sometime my wife says differently..... :-)
Regards,
Rob.
LOL! Thanks, but not really....I just adapted it from another "delete files older than" script, and as I said, I haven't tested it that much.....hopefully it works....give it a whirl.....
P.S. I don't like fancy pants that much either.....I'm not much of a "colourful" guy.....I tend to play it *safe* in the fasion sense......although sometime my wife says differently..... :-)
Regards,
Rob.
ASKER
Thank you!
ASKER
I would like to do a pattern match on the files (such as *.bak). Can that be added easily?