Prev: Searching for Field Names
Next: Regular expression : f(" l'éléphant blEu-azUr ") = " L'Éléphant Bleu-Azur "
From: LikeToCode on 6 Feb 2010 21:36 Here is a subroutine that will read your text file and copy the folders to any destination you supply (strDestination). The script will first check and see if the destination exists, if it does not then it will create it. As for a progressbar, this is VBScript NOT VB so you cannot have the same type of progressbar but there are options. In this script an IE Explorer window is opened and it displays the file being copied, so you can read it the script will sleep for 1 sec. If an error is detected the error number, description and the last file copied will be displayed in red in the IE window for 20 seconds. Sub CopyFolders() On Error Resume Next strDestination = "D:\MyCopies\" 'USB Drive If objFSO.FolderExists(strDestination) Then Set objExplorer = WScript.CreateObject _("InternetExplorer.Application") '"progressbar" starts here. With objExplorer .Navigate "about:blank" .ToolBar = 0 .StatusBar = 0 .Width = 400 .Height = 200 .Left = 0 .Top = 0 Do While (objExplorer.Busy) Wscript.Sleep(200) Loop .Visible = 1 Set objFromFile = objFSO.OpenTextFile("C:\SearchLog.txt", 1) _ 'the copy files starts here. Do Until objFromFile.AtEndOfStream strFolder = objFromFile.ReadLine .Document.Body.InnerHTML = "<b>Copying:</b> " & strFolder WScript.Sleep(1000) 'Sleeps 1 second so you can read the file name displayed in the explorer window. objFSO.CopyFolder strFolder, strDestination, True If Err <> 0 Then .Document.Body.InnerHTML = "<b><font color='red'>ERROR: " & _ Hex(Err.Number) & " " & Err.Description & "<br /><br /><b>Copying:</b> " & strFolder & "</b></font>" WScript.Sleep(20000) 'If error is detected explorer window will stay open for 20 seconds. End If Loop .Document.Body.InnerHTML = "<b>Copy action complete.</b>" End With Wscript.Sleep 3000 objExplorer.Quit objFromFile.Close() Else objFSO.CreateFolder(strDestination) 'creates the folder CopyFolders() 'calls this sub routine again End If End Sub
First
|
Prev
|
Pages: 1 2 Prev: Searching for Field Names Next: Regular expression : f(" l'éléphant blEu-azUr ") = " L'Éléphant Bleu-Azur " |