rstanberry
MIS
I'm trying to move all files not modified in the last 24 hours to a new folder but if it already exists I want to add an incremental number to the filename so that it copies.
Here is what I have so far.
Option Explicit
Const FOLDER = "\\Server\g$\Sharename"
Const BACKUP_FOLDER = "\\Server\d$\Sharename"
wscript.echo "Moving All Files Not Modified Last 24 Hours"
Dim objFSO, objFolder, objFile, filecount
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FOLDER)
On error resume next
filecount=0
For Each objFile In objFolder.Files
If objFile.DateLastModified < DateAdd("d", -1, Now) then
wscript.echo "Attempting to move file " & FOLDER & "\" & objFile.Name & " to " & BACKUP_FOLDER
objFile.Move(BACKUP_FOLDER & "\" & objFile.Name)
if Err > 0 then
wscript.echo "Error encountered moving file, The error is " & Err.Description
Err.clear
else
filecount = filecount + 1
wscript.echo objFile.name & " File Moved to backup folder"
End if
End If
Next
Any Ideas?
Here is what I have so far.
Option Explicit
Const FOLDER = "\\Server\g$\Sharename"
Const BACKUP_FOLDER = "\\Server\d$\Sharename"
wscript.echo "Moving All Files Not Modified Last 24 Hours"
Dim objFSO, objFolder, objFile, filecount
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FOLDER)
On error resume next
filecount=0
For Each objFile In objFolder.Files
If objFile.DateLastModified < DateAdd("d", -1, Now) then
wscript.echo "Attempting to move file " & FOLDER & "\" & objFile.Name & " to " & BACKUP_FOLDER
objFile.Move(BACKUP_FOLDER & "\" & objFile.Name)
if Err > 0 then
wscript.echo "Error encountered moving file, The error is " & Err.Description
Err.clear
else
filecount = filecount + 1
wscript.echo objFile.name & " File Moved to backup folder"
End if
End If
Next
Any Ideas?