I have folder structure for user in file server as follows
Root folder a
file 3 ....
file 2 .....
file 2 ..
i want to browse through all the nested folders and move all the files older than 60days to current date to another drive folder ( pref in the same structure . if it is too complicated atleaset to single folder) in the same machine .
I googled a bit and i found the following script which works fine but only for the files in the folder mentioned in the path. it does not browse all the nested folders and trnasfers the files. Can some expert show me how to tweak it to serve the above purpose.
On Error Resume Next
Dim fso, FileSet, Path, File, DDiff, Date1, Date2, DestPath
Path = "C:\D_DATA\Files"
DestPath = "C:\Fileold\"
'DestPath must end with \
FileSet = GetDirContents(Path)
For each File in FileSet
Set File = fso.GetFile(Path & "\" & File)
Date1 = File.DateLastModified
Date2 = Now()
DDiff = Abs(DateDiff("d", Date1, Date2))
If DDiff >= 60 Then
If Not fso.FileExists(DestPath & File.Name) Then
wscript.echo "Unable to move file [" & File.Name & "]. A file by this name already exists in the target directory."
Dim FileCollection, aTmp(), i
Set fso = CreateObject("Scripting.FileSystemObject")
Set FileCollection = fso.GetFolder(FolderPath).Files
Redim aTmp(FileCollection.count - 1)
i = -1
For Each File in FileCollection
i = i + 1
aTmp(i) = File.Name
GetDirContents = aTmp