Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Archive Script for Folders 1

Status
Not open for further replies.

Kadalynn

Programmer
Mar 20, 2002
6
US
I have a report that rights to a folder ever 1/2 hour. As you can imagine it gets pretty big. Normally I just do in every other week and delete out the files. Well my boss would like me to create a script that can run from the task menu. This script would go in and clean out the folder of any files over 2 weeks old and put them in another directory.

Well here is my question. How do I do that? I haven't been at this very long and really need some help figuring this out.


Thanks,
Kadalynn
 
I just started searching for an answer to a very similar problem.

Did you ever get an answer?

-Jaxn
 
No I never did find a way to do it from the task menu. I ended up adding some code to my web page to look for a date older than two weeks and move it to the archive directory. It does this each time the page is opened. It made the page load faster and made our searches easeir. If you want to try this I can copy the code for you.


Thanks,
Kadalynn
 
This should start you off nicely. I left off where the date comparisons come in, because I'm a bit rusty on that part.

---
directory = "c:\directory\"

set fs = createobject("Scripting.FileSystemObject")
set f = fs.GetFolder(directory)
set fc = f.Files

for each file in fc
set fs2 = createobject("scripting.FileSystemObject")
set f2 = fs2.GetFile(directory & file.name)
the_date = f2.DateCreated
...
next
---

When you get to ..., that's where you do your date check. If the_date is older than 14 days, then do an f2.delete.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top