Avatar of BlairBrenner
BlairBrenner
Flag for United States of America

asked on 

How To Move a File and Return It Within this Script

I have the following script which was modified in ID22046996.  I now need to add a step.
The step I need to add is to move the file to a predefined temporary folder and then move it back to it's original location.  This is done inside a loop.  A program call quickscan acts on the file while in the temporary location.
The points where I believe the code needs to be added is in CAPS.
Thanks in advance

Dim fso, WshShell, startFolder, targetApp, args1, args2

Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")

startFolder = "L:\Junk\02_Split Input\Test1"
targetApp = Chr(34) & "C:\Program Files\EMC Captiva\QuickScan\quickscn.exe" & Chr(34)
args1= " /cmd statusreport=c:\JCHA\QuickScan_Error_Logs\QSStatus.txt /scan path="
args2= ",profile=JCHA Split Naming 0721 cmd line,rootfilename="
args3= ",showcontinuedlg=0,batchtype=custom /exit"

SearchForFiles startFolder

Function SearchForFiles(folderName)
    Dim folder, file, fileCollection, folderCollection, subFolder, oExec

    TempFolder = "L:\Junk\02B_Temp Input"
    OutPutFolder = "L:\Junk\03_Split Output\Test1"
    Set folder = fso.GetFolder(folderName)
    Set fileCollection = folder.Files
    strParentFolder = folder.ParentFolder.Name
    strFolderName = folder.Name
    For Each file In fileCollection
      strFileName = Mid(file.name, 1, Len(Mid(file.name, 1, InStrRev(file.name, ".") - 1)))
MOVE FILE BEING PROCESSED TO THE TempFolder
      Set oExec = WshShell.Exec(targetApp & args1 & OutPutFolder & args2 & strFolderName & "_" &strFileName & args3)
      Do While oExec.Status = 0
         WScript.Sleep 100
      Loop
MOVE FILE BEING PROCESSED BACK TO ORIGINAL LOCATION
    Next

    Set folderCollection = folder.SubFolders
    For Each subFolder In folderCollection
       SearchForFiles subFolder.Path
    Next
End Function            
Visual Basic ClassicWindows XPVB Script

Avatar of undefined
Last Comment
BlairBrenner

8/22/2022 - Mon