Jonathan Duane
2010-03-16 21:54:20 UTC
Hi,
I am new enough to VB and so far i have been lucky enough to get code
from some really helpful guys at Experts Exchange the script i have so
far is
Set objFSO = CreateObject("Scripting.FileSystemObject")
SOURCE = "C:\jtest"
TARGET1 = "c:\jtest1"
TARGET2 = "c:\jtest2"
TARGET3 = "c:\jtest3"
Main
Sub Main
'Verify if source folder exists
If Not (objFSO.FolderExists(SOURCE)) Then
MsgBox "Source Folder Missing"
Else
'Run the moveFiles function
moveFiles Source, Target1
moveFiles Source, Target2
moveFiles Source, Target3
'Delete the TARGET folder (and contents)
objFSO.DeleteFolder SOURCE,Force
'Recreate TARGET folder
objFSO.CreateFolder SOURCE
'Wait time before checking SOURCE again
WScript.Sleep 5000
Main
End If
End Sub
Function moveFiles(copysource, ctarget)
'Create target directory if does not exist
If Not (objFSO.FolderExists(ctarget)) Then
objFSO.CreateFolder(ctarget)
End If
'Copy files from SOURCE to TARGET
objFSO.CopyFolder copysource, ctarget
End Function 'replicateFolders
But as the guys have pointed out when files come into the souce folder
and are bigger than 1 oe 2 mbs the script will grab them and them in
when tey havent fully transferred, is there anyway of putting a line
into the code where it says wait til the file hasnt been accessed for
x amount of seconds???
I am new enough to VB and so far i have been lucky enough to get code
from some really helpful guys at Experts Exchange the script i have so
far is
Set objFSO = CreateObject("Scripting.FileSystemObject")
SOURCE = "C:\jtest"
TARGET1 = "c:\jtest1"
TARGET2 = "c:\jtest2"
TARGET3 = "c:\jtest3"
Main
Sub Main
'Verify if source folder exists
If Not (objFSO.FolderExists(SOURCE)) Then
MsgBox "Source Folder Missing"
Else
'Run the moveFiles function
moveFiles Source, Target1
moveFiles Source, Target2
moveFiles Source, Target3
'Delete the TARGET folder (and contents)
objFSO.DeleteFolder SOURCE,Force
'Recreate TARGET folder
objFSO.CreateFolder SOURCE
'Wait time before checking SOURCE again
WScript.Sleep 5000
Main
End If
End Sub
Function moveFiles(copysource, ctarget)
'Create target directory if does not exist
If Not (objFSO.FolderExists(ctarget)) Then
objFSO.CreateFolder(ctarget)
End If
'Copy files from SOURCE to TARGET
objFSO.CopyFolder copysource, ctarget
End Function 'replicateFolders
But as the guys have pointed out when files come into the souce folder
and are bigger than 1 oe 2 mbs the script will grab them and them in
when tey havent fully transferred, is there anyway of putting a line
into the code where it says wait til the file hasnt been accessed for
x amount of seconds???