Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop until no more files exist

Status
Not open for further replies.

lpb71

Technical User
Mar 10, 2004
57
GB
My script below checks the status of a file creation and reports the size every few seconds. The file is named bxxxsr01.0, however my application creates a second and maybe third file if the file exceeds 2gb. I need to get my script to loop until all the bxxxxsr01.x have been reported on and also add the size of bxxxsr01.0 to bxxxsr01.1 and so on as they are created.


'Set Explorer Objects
Set objExplorer = CreateObject("InternetExplorer.Application")
Set fso = CreateObject("Scripting.FileSystemObject")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 400
objExplorer.Height = 200
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Visible = 1
objExplorer.resizable =0

do While (objExplorer.Busy)
Loop

Set objDocument = objExplorer.Document
objDocument.Open
objDocument.WriteLn "<html><head><title>LREP Data Replication</title></head>"
objDocument.WriteLn "<body bgcolor='white'>"
objDocument.WriteLn "Replicating Data to USB Device. Please Wait....<p>"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("b" + (branchid) + "sr01.0")


FileSize1 = (objFile.Size)/1024
wscript.sleep 10000
FileSize2 = (objFile.Size)/1024


'Launch Progress screen

Do Until FileSize1 = FileSize2
wscript.sleep 3000
objDocument.WriteLn("File Size so far =" & (objFile.Size)/1024 & " kb <br>")
objDocument.Close
objDocument.Open
objDocument.WriteLn "<html><head><title>LREP Data Replication</title></head>"
objDocument.WriteLn "<body bgcolor='white'>"
objDocument.WriteLn "Replicating Data to USB Device. Please Wait....<p>"
FileSize1 = (objFile.Size)
objDocument.WriteLn("File Size so far =" & (objFile.Size)/1024 & " Kb <br>")
wscript.sleep 3000
FileSize2 = (objFile.Size)
objDocument.Close
Loop
 
'all totally horrid for 100 reasons :)
'not sure if you will actually need to refresh the
'Set objFolder every time you call the doSomething
'might save time if you dont need to...havent tested
Set objFolder = FSO.GetFOlder("location of where files are")

Do
Call doSomething(objFolder)
Wscript.Sleep 3000
Loop


Sub doSomething(ByVal objFolder)
Dim aFile
For Each aFile In objFolder.Files
If UCASE(Left(aFile.Name, 5)) = "HELLO" Then
Wscript.Echo aFile.Name & "=" & aFile.Size
End If
Next
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top