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

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.
dutboyAsked:
Who is Participating?
 
mvidasCommented:
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
 
dutboyAuthor Commented:
Thanks for such a  quick response and Matt it worked a treat.  Many thanks....
0
 
mvidasCommented:
Glad to help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.