?
Solved

Move Files from Directory 1 to Directory 2 that have not been accessed in the last 30 days.

Posted on 2006-03-23
4
Medium Priority
?
292 Views
Last Modified: 2010-08-05
All,

I hope you can help,  I need a script file to move files from one directory to another according to their last accessed date (not how old the files are).

Any files not accessed in the last 31days need to be moved to an archive folder.

This is on a windows 2000 server.

Sounds simple, but i stumped, Im quite new to this scripting business..

I hope you can help, and am sorry if this has been answered already,but i just cant find the solution.
0
Comment
Question by:dutboy
  • 2
4 Comments
 
LVL 35

Accepted Solution

by:
mvidas earned 2000 total points
ID: 16269253
dutboy,

Paste the following into a new text file, and save it as something with the extension of .vbs:

 Dim FSO, f, fld, fls, vOrigDir, vNewDir
 vOrigDir = "C:\foldername\"
 vNewDir = "C:\folder 2\"
 Set FSO = CreateObject("scripting.filesystemobject")
 Set fld = FSO.GetFolder(vOrigDir)
 Set fls = fld.Files
 For Each f In fls
  If f.DateLastAccessed < DateValue(CStr(Now)) - 30 Then f.Move vNewDir
 Next
 Set FSO = Nothing
 Set f = Nothing
 Set fld = Nothing
 Set fls = Nothing
 Set vOrigDir = Nothing
 Set vNewDir = Nothing

To run it, just double click the .vbs file.  You can also put this into windows scheduler to run it at specified intervals, if that helps you.  Please let us know if you need any help!
Matt
0
 

Author Comment

by:dutboy
ID: 16269865
Thanks for such a  quick response and Matt it worked a treat.  Many thanks....
0
 
LVL 35

Expert Comment

by:mvidas
ID: 16269898
Glad to help!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Introduction to Processes

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question