I have a script that at one point would search folders and present files that were designated by a date limiter. It would then simply delete these files. The new twist is that I have to now move these files to a local drive for deep archiving while maintaining their folder structure. I am a scripting novice and have attempted to use the Movefile object to no success. I am quickly running out of space so my time to tinker is growing short. I am including the original script for any suggestions.
thank you
Dim aryNameSpaces(6), strSrcDrive, strDest, intRetainDays
strSrcDrive = "D:\Shares\Archives"
intRetainDays = 397
aryNameSpaces(0) = "Prod1"
aryNameSpaces(1) = "Prod2"
aryNameSpaces(2) = "Prod3"
aryNameSpaces(3) = "Test1"
aryNameSpaces(4) = "Test2"
aryNameSpaces(5) = "Test3"
aryNameSpaces(6) = "Test4"
strYear = Year(Date)
strMonth = Month(Date)
If strMonth < 10 Then
strMonth = "0" & strMonth
End If
strDay = Day(Date)
If strDay < 10 Then
strDay = "0" & strDay
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
For Each NAMESPACE In aryNameSpaces
If objFSO.FolderExists(strSrcDrive & "\" & NAMESPACE) Then
subScanFolders NAMESPACE
End If
Next
Sub subScanFolders(NAMESPACE)
Set objSubFolders = objFSO.GetFolder(strSrcDrive & "\" & NAMESPACE).SubFolders
For Each FOLDER In objSubFolders
strFolderDate = DateSerial(Left(FOLDER.Name,4), Mid(FOLDER.Name,5,2), Right(FOLDER.Name,2))
If strFolderDate < Date - intRetainDays Then
objFSO.DeleteFolder FOLDER.Path
End If
Next
End Sub
thank you
Dim aryNameSpaces(6), strSrcDrive, strDest, intRetainDays
strSrcDrive = "D:\Shares\Archives"
intRetainDays = 397
aryNameSpaces(0) = "Prod1"
aryNameSpaces(1) = "Prod2"
aryNameSpaces(2) = "Prod3"
aryNameSpaces(3) = "Test1"
aryNameSpaces(4) = "Test2"
aryNameSpaces(5) = "Test3"
aryNameSpaces(6) = "Test4"
strYear = Year(Date)
strMonth = Month(Date)
If strMonth < 10 Then
strMonth = "0" & strMonth
End If
strDay = Day(Date)
If strDay < 10 Then
strDay = "0" & strDay
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
For Each NAMESPACE In aryNameSpaces
If objFSO.FolderExists(strSrcDrive & "\" & NAMESPACE) Then
subScanFolders NAMESPACE
End If
Next
Sub subScanFolders(NAMESPACE)
Set objSubFolders = objFSO.GetFolder(strSrcDrive & "\" & NAMESPACE).SubFolders
For Each FOLDER In objSubFolders
strFolderDate = DateSerial(Left(FOLDER.Name,4), Mid(FOLDER.Name,5,2), Right(FOLDER.Name,2))
If strFolderDate < Date - intRetainDays Then
objFSO.DeleteFolder FOLDER.Path
End If
Next
End Sub