chriskuyper
Technical User
Hi,
I'm using the copyhere command to transfer a large amount of files into a zipfile before moving the zip file to a different location on the network (and it has to happen in this order).
I want to wait with moving the file across the network until the copying is done. The only thing I could think of was a Do While loop with a sleep command in it but this is really messing up my system performance though it does seem to work. Can you think of a better way of waiting for the copyhere to complete?
I've included the code I'm using below. All the way at the bottom are two loops. The second loop is the one that waits for the copyhere command to complete. The loop before it is the copyhere command which reads a textfile to find the folders it needs to include.
Your help would be very much appreciated.
Const FOF_SIMPLEPROGRESS = &H100
Set objShell = CreateObject("Shell.Application")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set DestFldr=objShell.NameSpace("C:\test1\"&UserName&" "&Date()&".zip")
Set fso = nothing
Set ts = nothing
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\test1\test.txt",ForReading)
i = 0
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
DestFldr.CopyHere (strNextLine)", FOF_SIMPLEPROGRESS = &H100
i = i + 1
Loop
Do While objShell.NameSpace("C:\test1\"&UserName&" "&Date()&".zip").items.Count < i
wscript.sleep 5000
Loop
I'm using the copyhere command to transfer a large amount of files into a zipfile before moving the zip file to a different location on the network (and it has to happen in this order).
I want to wait with moving the file across the network until the copying is done. The only thing I could think of was a Do While loop with a sleep command in it but this is really messing up my system performance though it does seem to work. Can you think of a better way of waiting for the copyhere to complete?
I've included the code I'm using below. All the way at the bottom are two loops. The second loop is the one that waits for the copyhere command to complete. The loop before it is the copyhere command which reads a textfile to find the folders it needs to include.
Your help would be very much appreciated.
Const FOF_SIMPLEPROGRESS = &H100
Set objShell = CreateObject("Shell.Application")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set DestFldr=objShell.NameSpace("C:\test1\"&UserName&" "&Date()&".zip")
Set fso = nothing
Set ts = nothing
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\test1\test.txt",ForReading)
i = 0
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
DestFldr.CopyHere (strNextLine)", FOF_SIMPLEPROGRESS = &H100
i = i + 1
Loop
Do While objShell.NameSpace("C:\test1\"&UserName&" "&Date()&".zip").items.Count < i
wscript.sleep 5000
Loop