By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,057 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,057 IT Pros & Developers. It's quick & easy.

Redid the script

P: 20
I've redid the script to get all files in a folder/subfolders that are > 730 days and move to another folder(archive) however I'm missing something. The script runs, and I don't get any errors but no move is taking place. Any suggestions?
See code below


SOURCE = "C:\Documents and Settings\barnesl.CHIPLEY\Exercise starts\VB.NET"
TARGET = "C:\Documents and Settings\barnesl.CHIPLEY\archives\"

Dim fso, SourceObj, TargetObj, fileObj
Set fso = CreateObject("Scripting.FileSystemObject")
Set SourceObj = fso.GetFolder(SOURCE)
set targetobj = fso.GetFolder(target)

sub recurse( byref sourceobj)

set subfolders = sourceobj.subfolders
set fileobj = sourceobj.files

For Each fileobj in files

If DateDiff("d", fileobj.DateLastModified, Now) > 730 Then
fileobj.Move (Targetobj)
End If

for each folder in subfolders
recurse folder

set subfolders = nothing
set fileobj = nothing

end sub
Dec 7 '07 #1
Share this Question
Share on Google+
2 Replies

Expert 5K+
P: 8,434
Perhaps set fileobj = sourceobj.files should be set files = sourceobj.files ?
Dec 10 '07 #2

Expert 5K+
P: 8,434
By the way, I recommend always using Option Explicit to force variable declaration.
Dec 10 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.