Jump to content

FileCopy slow


Recommended Posts

Using FileCopy to copy faily large files from a mapped drive to local drive and it takes about 8 minutes before the script continues, yet the file is there and can launch the file, but the FileCopy command is still running and the script is hanging. I have also tried to copy the file using a command line and it runs much faster but I do not want to open up another window. Any ideas?

Link to comment
Share on other sites

The files are around 500MB audio files here is the script that I have now that I am working with. What I need to do is simplify a Wav file converting. The system making the wav files are making them in 4 channel recordings which can not be played back in Media Player so I am converting them to 2 channel wav files with Audacity. Here is the script that I have now

#include <GUIConstants.au3>
#include <array.au3>
#include <Process.au3>

; -----------------------------------------------------------------------------------------------------
Dim $RoomSelect, $DirList, $RecInfo, $RecDirectory,$CourtRm, $List, $Selected, $Info
Dim $Audacity = "C:\Program Files\Audacity\audacity.exe" ; Path to the executable for Audacity
; -----------------------------------------------------------------------------------------------------
Call ("Directories")
Call ("Input")
Call ("Display")
Call ("SelectGUI")
Call ("Copy")
Call ("Convert")
Call ("DelDrive")
Exit
; -----------------------------------------------------------------------------------------------------
Func Directories()
$AddDrive = DriveMapAdd ("m:", "\\Cts-trf-fps-002\Shared\Court Recordings")
EndFunc
; -----------------------------------------------------------------------------------------------------
Func Input()
    $RoomSelect = GUICreate("Select Court Room",250, 175)
    GUICtrlCreateLabel("Select Court Rm.",20,20)
    $DirList = GUICtrlCreateCombo("Court Room", 110, 20,75)
    GUICtrlSetData ($DirList, "1A|2A|2B|2C|2D|2E|2F","1A")
    GUICtrlCreateLabel("Recording Info", 20, 60)
    $RecInfo = GUICtrlCreateInput("", 110, 60,100)
    $Select1 = GUICtrlCreateButton ("Select", 100, 110)
    GUISetState ()      
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                GUIDelete($RoomSelect)
                ExitLoop
            Case $Msg = $Select1 
                $Selected = GUICtrlRead($DirList)
                $Info = GUICtrlRead($RecInfo)
                GUIDelete($RoomSelect)
                ExitLoop
        EndSelect
    Wend
    $CourtRm = $Selected
    $RecDirectory = $Selected & "\*" & $Info
EndFunc
; -----------------------------------------------------------------------------------------------------
Func Display()
    $Recording = ("m:\" &  $RecDirectory & "*.*")
    $search = FileFindFirstFile($Recording) 
    If $search = -1 Then
        MsgBox(0, "Error", "No files/directories matched the search pattern")
        Exit
    EndIf
    While 1
        $file = FileFindNextFile($search) 
        If @error Then ExitLoop
        $List = $List & $file & "|"
    WEnd
    $FileList = StringSplit($List,";")
EndFunc
; -----------------------------------------------------------------------------------------------------
Func SelectGUI()
    $SelectRecording = GUICreate("Select Recording")  ; will create a dialog box that when displayed is centered
    GUISetState (@SW_SHOW)       ; will display an empty dialog box
    $Listing = GUICtrlCreateList("",50,50, 300,200)
    GUICtrlSetLimit(-1,200) ; to limit horizontal scrolling
    $Select = GUICtrlCreateButton("Select", 175,300, 50, 30)
    GUICtrlSetData($Listing,$List)
    ; Run the GUI until the dialog is closed
    GUISetState ()      
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                GUIDelete($SelectRecording)
            
            Case $Msg = $Select 
                $Selected = GUICtrlRead($Listing)
                GUIDelete($SelectRecording)
                ExitLoop
        EndSelect
    Wend
MsgBox(0,"Selected File", $Selected)
EndFunc
; -----------------------------------------------------------------------------------------------------
Func Copy()
    $Copied = FileCopy ("m:\" & $CourtRm & "\" & $Selected, "c:\wav_in",9)
    ;Run ("cmd.exe","m:\")
    ;WinWaitActive ("C:\WINDOWS\system32\cmd.exe")
    ;WinActivate("C:\WINDOWS\system32\cmd.exe")
    ;Send("{ENTER}")
    ;Send ("cd " & $CourtRm)
    ;Send ("{ENTER}")
    ;Send ("copy " & $Selected & " c:\wav_in")
    ;Send ("{ENTER}")
    ;Sleep(10000)
    ;WinClose ("C:\WINDOWS\system32\cmd.exe")
    ;WinwaitClose ("C:\WINDOWS\system32\cmd.exe")
EndFunc
; -----------------------------------------------------------------------------------------------------
Func Convert()
    $AudacityCheck = FileExists($Audacity)
    If $AudacityCheck = 0 Then
        MsgBox(0,"Audacity", "Audacity is not installed please place request to have Audacity installed")
        Exit
    EndIf
Run ($Audacity)
WinWait("Audacity")
WinActivate("Audacity")
Send ("^o")
Send ("C:\wav_in\" & $Selected)
Send("{ENTER}")
$SelectedLen = StringLen($Selected)
$TitleLength = $SelectedLen - 4
$TitleMatch = StringLeft($Selected,$TitleLength)
WinWaitActive ($TitleMatch)
Send ("!f")
Send ("e")
WinWaitActive("Save WAV (Microsoft) File As:")
WinActive("Save WAV (Microsoft) File As:")
Send("c:\wav_out\" & $TitleMatch)
Send ("{ENTER}")
WinWaitActive($TitleMatch)
Send ("!F")
Send ("x")

EndFunc
; -----------------------------------------------------------------------------------------------------
Func DelDrive()
$DelDrive = DriveMapDel ("M:")
EndFunc
Edited by mnchartier
Link to comment
Share on other sites

The files are around 500MB audio files here is the script that I have now that I am working with. What I need to do is simplify a Wav file converting. The system making the wav files are making them in 4 channel recordings which can not be played back in Media Player so I am converting them to 2 channel wav files with Audacity. Here is the script that I have now

#include <GUIConstants.au3>
#include <array.au3>
#include <Process.au3>

; -----------------------------------------------------------------------------------------------------
Dim $RoomSelect, $DirList, $RecInfo, $RecDirectory,$CourtRm, $List, $Selected, $Info
Dim $Audacity = "C:\Program Files\Audacity\audacity.exe" ; Path to the executable for Audacity
; -----------------------------------------------------------------------------------------------------
Call ("Directories")
Call ("Input")
Call ("Display")
Call ("SelectGUI")
Call ("Copy")
Call ("Convert")
Call ("DelDrive")
Exit
; -----------------------------------------------------------------------------------------------------
Func Directories()
$AddDrive = DriveMapAdd ("m:", "\\Cts-trf-fps-002\Shared\Court Recordings")
EndFunc
; -----------------------------------------------------------------------------------------------------
Func Input()
    $RoomSelect = GUICreate("Select Court Room",250, 175)
    GUICtrlCreateLabel("Select Court Rm.",20,20)
    $DirList = GUICtrlCreateCombo("Court Room", 110, 20,75)
    GUICtrlSetData ($DirList, "1A|2A|2B|2C|2D|2E|2F","1A")
    GUICtrlCreateLabel("Recording Info", 20, 60)
    $RecInfo = GUICtrlCreateInput("", 110, 60,100)
    $Select1 = GUICtrlCreateButton ("Select", 100, 110)
    GUISetState ()      
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                GUIDelete($RoomSelect)
                ExitLoop
            Case $Msg = $Select1 
                $Selected = GUICtrlRead($DirList)
                $Info = GUICtrlRead($RecInfo)
                GUIDelete($RoomSelect)
                ExitLoop
        EndSelect
    Wend
    $CourtRm = $Selected
    $RecDirectory = $Selected & "\*" & $Info
EndFunc
; -----------------------------------------------------------------------------------------------------
Func Display()
    $Recording = ("m:\" &  $RecDirectory & "*.*")
    $search = FileFindFirstFile($Recording) 
    If $search = -1 Then
        MsgBox(0, "Error", "No files/directories matched the search pattern")
        Exit
    EndIf
    While 1
        $file = FileFindNextFile($search) 
        If @error Then ExitLoop
        $List = $List & $file & "|"
    WEnd
    $FileList = StringSplit($List,";")
EndFunc
; -----------------------------------------------------------------------------------------------------
Func SelectGUI()
    $SelectRecording = GUICreate("Select Recording")  ; will create a dialog box that when displayed is centered
    GUISetState (@SW_SHOW)       ; will display an empty dialog box
    $Listing = GUICtrlCreateList("",50,50, 300,200)
    GUICtrlSetLimit(-1,200) ; to limit horizontal scrolling
    $Select = GUICtrlCreateButton("Select", 175,300, 50, 30)
    GUICtrlSetData($Listing,$List)
    ; Run the GUI until the dialog is closed
    GUISetState ()      
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                GUIDelete($SelectRecording)
            
            Case $Msg = $Select 
                $Selected = GUICtrlRead($Listing)
                GUIDelete($SelectRecording)
                ExitLoop
        EndSelect
    Wend
MsgBox(0,"Selected File", $Selected)
EndFunc
; -----------------------------------------------------------------------------------------------------
Func Copy()
    $Copied = FileCopy ("m:\" & $CourtRm & "\" & $Selected, "c:\wav_in",9)
    ;Run ("cmd.exe","m:\")
    ;WinWaitActive ("C:\WINDOWS\system32\cmd.exe")
    ;WinActivate("C:\WINDOWS\system32\cmd.exe")
    ;Send("{ENTER}")
    ;Send ("cd " & $CourtRm)
    ;Send ("{ENTER}")
    ;Send ("copy " & $Selected & " c:\wav_in")
    ;Send ("{ENTER}")
    ;Sleep(10000)
    ;WinClose ("C:\WINDOWS\system32\cmd.exe")
    ;WinwaitClose ("C:\WINDOWS\system32\cmd.exe")
EndFunc
; -----------------------------------------------------------------------------------------------------
Func Convert()
    $AudacityCheck = FileExists($Audacity)
    If $AudacityCheck = 0 Then
        MsgBox(0,"Audacity", "Audacity is not installed please place request to have Audacity installed")
        Exit
    EndIf
Run ($Audacity)
WinWait("Audacity")
WinActivate("Audacity")
Send ("^o")
Send ("C:\wav_in\" & $Selected)
Send("{ENTER}")
$SelectedLen = StringLen($Selected)
$TitleLength = $SelectedLen - 4
$TitleMatch = StringLeft($Selected,$TitleLength)
WinWaitActive ($TitleMatch)
Send ("!f")
Send ("e")
WinWaitActive("Save WAV (Microsoft) File As:")
WinActive("Save WAV (Microsoft) File As:")
Send("c:\wav_out\" & $TitleMatch)
Send ("{ENTER}")
WinWaitActive($TitleMatch)
Send ("!F")
Send ("x")

EndFunc
; -----------------------------------------------------------------------------------------------------
Func DelDrive()
$DelDrive = DriveMapDel ("M:")
EndFunc
do you need to copy the file at all? i mean, it looks like you could just set the output path in audacity, so that it will put the converted file where you want it anyway...
Link to comment
Share on other sites

The import is even longer pulling it from the network drive

When Audacity uses Lame.dll. I also want to give an enduser to edit the volume on the channels also (to be added later by throwing up another message box prompting them to edit and then click ok to continue converting.

Edited by mnchartier
Link to comment
Share on other sites

ok just trying to copy a file that is cd size about 700 mb, from my usb drive takes about 15 minutes.. i tried it with a slightly smaller file and what i can see is this... lets say we are in your destination folder... with it saying that 700 mb is already there, well it truly isn't... it basically is either a false statement or it is just a empty file that is being filled up with the data it is reading. either way it isn't there as fast as what explorer may report. if it takes so much time to down load it through explorer expect roughtly the same time period that autoit will have to take... so if it takes me 20 minutes throught explorer (uncached) autoit won't be much faster than that time frame.....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...