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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dutboyAuthor Commented:
Thanks for such a  quick response and Matt it worked a treat.  Many thanks....
mvidasCommented:
Glad to help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.