Jump to content

filecopy error


Recommended Posts

Ok i've searched for a while and can't find an answer. I am writing a script to work with a file splitter. it is supposed to grab 700MB files off of CDs and tell you to put the next one in. After that it will run the program to put the pieces back together. THe problem is that before it gets done copying the first file it errors out. I know this because i have a check. Is there a limit or a timeout on Filecopy and what is it. Is there a better way to do this...here is the full code but the problem exist in the first filecopy in the build_file function

#include <GuiConstants.au3>
#include <File.au3>

$g_szVersion = "Auto Creator v1.0"
If WinExists($g_szVersion) Then Exit; It's already running
AutoItWinSetTitle($g_szVersion)

;;;;;;;;; Options;;;;;;;;;;;
Opt("CaretCoordMode", 1)      ;1=absolute, 0=relative, 2=client
Opt("ColorMode", 0)            ;0=RRGGBB color, 1=BBGGRR color
Opt("ExpandEnvStrings", 0)    ;0=don't expand, 1=do expand
Opt("ExpandVarStrings", 0)    ;0=don't expand, 1=do expand
Opt("FtpBinaryMode", 1)        ;1=binary, 0=ASCII
Opt("GUICloseOnESC", 0)        ;1=ESC won't close, 0=ESC closes
Opt("GUICoordMode", 1)        ;1=absolute, 0=relative, 2=cell
Opt("GUIOnEventMode", 1)      ;0=disabled, 1=OnEvent mode enabled
Opt("GUIResizeMode", 0)        ;0=no resizing, <1024 special resizing
Opt("MouseClickDelay", 10)    ;10 milliseconds
Opt("MouseClickDownDelay", 10);10 milliseconds
Opt("MouseClickDragDelay", 250);250 milliseconds
Opt("MouseCoordMode", 1)      ;1=absolute, 0=relative, 2=client
Opt("MustDeclareVars", 1)      ;0=no, 1=require pre-declare
Opt("PixelCoordMode", 1)      ;1=absolute, 0=relative, 2=client
Opt("RunErrorsFatal", 1)      ;1=fatal, 0=silent set @error
Opt("SendAttachMode", 0)      ;0=don't attach, 1=do attach
Opt("SendCapslockMode", 1)    ;1=store and restore, 0=don't
Opt("SendKeyDelay", 5)        ;5 milliseconds
Opt("SendKeyDownDelay", 1)    ;1 millisecond
Opt("TrayIconDebug", 0)        ;0=no info, 1=debug line info
Opt("TrayIconHide", 1)        ;0=show, 1=hide tray icon
Opt("WinWaitDelay", 250)      ;250 milliseconds
Opt("WinDetectHiddenText", 0)  ;0=don't detect, 1=do detect
Opt("WinSearchChildren", 1)    ;0=no, 1=search children also
Opt("WinTextMatchMode", 1)    ;1=complete, 2=quick
Opt("WinTitleMatchMode", 2)    ;1=start, 2=subStr, 3=exact, 4=advanced
;;;;;;;; Variables;;;;;;;;;;
Dim $start, $browse, $file;GUI controls
Dim $path, $dest;Directories
Dim $parent;win controls


;;;;;;;;; Program;;;;;;;;;;;

; GUI
GUICreate($g_szVersion, 500, 100)
GUISetIcon(@SystemDir & "\cmd.exe", 0)

; GUI COMPONANTS
$file = GUICtrlCreateInput("", 56, 25, 350, -1, $ES_READONLY)
GUICtrlCreateLabel("First file:", 10, 30)


; BUTTON
$start = GuiCtrlCreateButton("Start", 210, 70, 80, 20, $BS_DEFPUSHBUTTON)
$browse = GuiCtrlCreateButton("Browse", 410, 25, 80, 20)

; SET EVENTS
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUICtrlSetOnEvent($start, "Start")
GUICtrlSetOnEvent($browse, "Browse")

MsgBox(48, "Important", "Please move this file to your computer if you have not already before you run it.")

; SHOW GUI
GuiSetState(@SW_SHOW)

; MAIN PROGRAM LOOP
While 1
    Sleep(50)
WEnd

Func Quit()
    Exit 0
EndFunc

Func Quit_Error()
    MsgBox(0,"Error","An error occured and the program must quit!")
    Exit 0
EndFunc

Func Start()
    Disable()
    If GUICtrlRead($file) = "" Then
        MsgBox(0, "Error", "Please select a file.")
    Else
        If MsgBox(4, "", "Begin process? Depending on the size and number of files this could take a while.") = 7 Then
            Done()
            Return
        EndIf
        Build_File()
    EndIf
    Done()
EndFunc

Func Browse()
    $path = FileOpenDialog("Please select the first file...", "", "Split Files(*.1)", 3)
    GUICtrlSetData($file, $path)
EndFunc

Func Disable()
    GUICtrlSetState($start, $GUI_DISABLE)
    GUICtrlSetState($browse, $GUI_DISABLE)
    
EndFunc

Func Done()
    GUICtrlSetState($start, $GUI_ENABLE)
    GUICtrlSetState($browse, $GUI_ENABLE)
    
EndFunc

Func Build_File()
    Local $part_num = 1
    Local $drive = StringLeft($path,3)
    Local $parts = StringSplit(StringMid($path, 4),".")
    Local $filepart = StringSplit($parts[1],"\")
    Local $filename = $filepart[$filepart[0]]
    $dest = FileSelectFolder("Where would you like to save the file?", "", 7)
    Do
        MsgBox(0,"","Please insert disk " & $part_num & " and then press OK")
        While DriveStatus($drive) = 'NOTREADY'
            Sleep(100)
        WEnd
        GUICtrlSetData($file, "Copying Disk " & $part_num)
        If NOT FileCopy($drive & $parts[1] & '.' & $parts[2] & '.' & $part_num, $dest & '\' & $filename & '.' & $parts[2] & '.' & $part_num, 1) Then
            Quit_Error()
        EndIf
        $part_num = $part_num + 1
    Until FileExists($drive & StringLeft($parts[1], StringLen($parts[1])- StringLen($filename)) & "Create_" & $filename & ".exe")
    MsgBox(0,"first",$drive & StringLeft($parts[1], StringLen($parts[1])- StringLen($filename)) & "Create_" & $filename & ".exe")
    FileCopy($drive & StringLeft($parts[1], StringLen($parts[1])- StringLen($filename)) & "Create_" & $filename & ".exe", $dest & '\' & "Create_" & $filename & ".exe")
    Run($dest & '\' & "Create_" & $filename & ".exe","",@SW_HIDE)
    WinWait("The File Splitter")
    WinActivate("The File Splitter")
    Send("{ENTER}")
    ProgressOn("Building...", "Percent complete:","",-1,-1,3)
    While WinExists("The File Splitter")
        Local $x = StatusbarGetText("The File Splitter")
        Local $array = StringSplit($x, "%")
        ProgressSet($array[1], $x)
    WEnd
    ProgressOff()
    Quit()    
EndFunc

Thansk for your help in advance

Edited by dumdum8684
Link to comment
Share on other sites

Ok i've searched for a while and can't find an answer. I am writing a script to work with a file splitter. it is supposed to grab 700MB files off of CDs and tell you to put the next one in. After that it will run the program to put the pieces back together. THe problem is that before it gets done copying the first file it errors out. I know this  because i have a check. Is there a limit or a timeout on Filecopy and what is it. Is there a better way to do this...here is the full code but the problem exist in the first filecopy in the build_file function

#include <GuiConstants.au3>
#include <File.au3>

$g_szVersion = "Auto Creator v1.0"
If WinExists($g_szVersion) Then Exit; It's already running
AutoItWinSetTitle($g_szVersion)

;;;;;;;;; Options;;;;;;;;;;;
Opt("CaretCoordMode", 1)      ;1=absolute, 0=relative, 2=client
Opt("ColorMode", 0)            ;0=RRGGBB color, 1=BBGGRR color
Opt("ExpandEnvStrings", 0)    ;0=don't expand, 1=do expand
Opt("ExpandVarStrings", 0)    ;0=don't expand, 1=do expand
Opt("FtpBinaryMode", 1)        ;1=binary, 0=ASCII
Opt("GUICloseOnESC", 0)        ;1=ESC won't close, 0=ESC closes
Opt("GUICoordMode", 1)        ;1=absolute, 0=relative, 2=cell
Opt("GUIOnEventMode", 1)      ;0=disabled, 1=OnEvent mode enabled
Opt("GUIResizeMode", 0)        ;0=no resizing, <1024 special resizing
Opt("MouseClickDelay", 10)    ;10 milliseconds
Opt("MouseClickDownDelay", 10);10 milliseconds
Opt("MouseClickDragDelay", 250);250 milliseconds
Opt("MouseCoordMode", 1)      ;1=absolute, 0=relative, 2=client
Opt("MustDeclareVars", 1)      ;0=no, 1=require pre-declare
Opt("PixelCoordMode", 1)      ;1=absolute, 0=relative, 2=client
Opt("RunErrorsFatal", 1)      ;1=fatal, 0=silent set @error
Opt("SendAttachMode", 0)      ;0=don't attach, 1=do attach
Opt("SendCapslockMode", 1)    ;1=store and restore, 0=don't
Opt("SendKeyDelay", 5)        ;5 milliseconds
Opt("SendKeyDownDelay", 1)    ;1 millisecond
Opt("TrayIconDebug", 0)        ;0=no info, 1=debug line info
Opt("TrayIconHide", 1)        ;0=show, 1=hide tray icon
Opt("WinWaitDelay", 250)      ;250 milliseconds
Opt("WinDetectHiddenText", 0)  ;0=don't detect, 1=do detect
Opt("WinSearchChildren", 1)    ;0=no, 1=search children also
Opt("WinTextMatchMode", 1)    ;1=complete, 2=quick
Opt("WinTitleMatchMode", 2)    ;1=start, 2=subStr, 3=exact, 4=advanced
;;;;;;;; Variables;;;;;;;;;;
Dim $start, $browse, $file;GUI controls
Dim $path, $dest;Directories
Dim $parent;win controls
;;;;;;;;; Program;;;;;;;;;;;

; GUI
GUICreate($g_szVersion, 500, 100)
GUISetIcon(@SystemDir & "\cmd.exe", 0)

; GUI COMPONANTS
$file = GUICtrlCreateInput("", 56, 25, 350, -1, $ES_READONLY)
GUICtrlCreateLabel("First file:", 10, 30)
; BUTTON
$start = GuiCtrlCreateButton("Start", 210, 70, 80, 20, $BS_DEFPUSHBUTTON)
$browse = GuiCtrlCreateButton("Browse", 410, 25, 80, 20)

; SET EVENTS
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUICtrlSetOnEvent($start, "Start")
GUICtrlSetOnEvent($browse, "Browse")

MsgBox(48, "Important", "Please move this file to your computer if you have not already before you run it.")

; SHOW GUI
GuiSetState(@SW_SHOW)

; MAIN PROGRAM LOOP
While 1
    Sleep(50)
WEnd

Func Quit()
    Exit 0
EndFunc

Func Quit_Error()
    MsgBox(0,"Error","An error occured and the program must quit!")
    Exit 0
EndFunc

Func Start()
    Disable()
    If GUICtrlRead($file) = "" Then
        MsgBox(0, "Error", "Please select a file.")
    Else
        If MsgBox(4, "", "Begin process? Depending on the size and number of files this could take a while.") = 7 Then
            Done()
            Return
        EndIf
        Build_File()
    EndIf
    Done()
EndFunc

Func Browse()
    $path = FileOpenDialog("Please select the first file...", "", "Split Files(*.1)", 3)
    GUICtrlSetData($file, $path)
EndFunc

Func Disable()
    GUICtrlSetState($start, $GUI_DISABLE)
    GUICtrlSetState($browse, $GUI_DISABLE)
    
EndFunc

Func Done()
    GUICtrlSetState($start, $GUI_ENABLE)
    GUICtrlSetState($browse, $GUI_ENABLE)
    
EndFunc

Func Build_File()
    Local $part_num = 1
    Local $drive = StringLeft($path,3)
    Local $parts = StringSplit(StringMid($path, 4),".")
    Local $filepart = StringSplit($parts[1],"\")
    Local $filename = $filepart[$filepart[0]]
    $dest = FileSelectFolder("Where would you like to save the file?", "", 7)
    Do
        MsgBox(0,"","Please insert disk " & $part_num & " and then press OK")
        While DriveStatus($drive) = 'NOTREADY'
            Sleep(100)
        WEnd
        GUICtrlSetData($file, "Copying Disk " & $part_num)
        If NOT FileCopy($drive & $parts[1] & '.' & $parts[2] & '.' & $part_num, $dest & '\' & $filename & '.' & $parts[2] & '.' & $part_num, 1) Then
            Quit_Error()
        EndIf
        $part_num = $part_num + 1
    Until FileExists($drive & StringLeft($parts[1], StringLen($parts[1])- StringLen($filename)) & "Create_" & $filename & ".exe")
    MsgBox(0,"first",$drive & StringLeft($parts[1], StringLen($parts[1])- StringLen($filename)) & "Create_" & $filename & ".exe")
    FileCopy($drive & StringLeft($parts[1], StringLen($parts[1])- StringLen($filename)) & "Create_" & $filename & ".exe", $dest & '\' & "Create_" & $filename & ".exe")
    Run($dest & '\' & "Create_" & $filename & ".exe","",@SW_HIDE)
    WinWait("The File Splitter")
    WinActivate("The File Splitter")
    Send("{ENTER}")
    ProgressOn("Building...", "Percent complete:","",-1,-1,3)
    While WinExists("The File Splitter")
        Local $x = StatusbarGetText("The File Splitter")
        Local $array = StringSplit($x, "%")
        ProgressSet($array[1], $x)
    WEnd
    ProgressOff()
    Quit()    
EndFunc

Thansk for your help in advance

<{POST_SNAPBACK}>

here's your problem...

If NOT FileCopy($drive & $parts[1] & '.' & $parts[2] & '.' & $part_num, $dest & '\' & $filename & '.' & $parts[2] & '.' & $part_num, 1) Then

add these two lines right above it to see for yourself.

msgbox(0,"source:",$drive & $parts[1] & '.' & $parts[2] & '.' & $part_num)
        msgbox(0,"dest:",$dest & '\' & $filename & '.' & $parts[2] & '.' & $part_num)
Link to comment
Share on other sites

here's your problem...

If NOT FileCopy($drive & $parts[1] & '.' & $parts[2] & '.' & $part_num, $dest & '\' & $filename & '.' & $parts[2] & '.' & $part_num, 1) Then

add these two lines right above it to see for yourself.

msgbox(0,"source:",$drive & $parts[1] & '.' & $parts[2] & '.' & $part_num)
        msgbox(0,"dest:",$dest & '\' & $filename & '.' & $parts[2] & '.' & $part_num)

<{POST_SNAPBACK}>

Ok did that...I don't see a problem with either the source or the dest. Am i missing something? The program works when i test it with a rather small file (15MB each, 5 files). It also works if i have the files already on the harddrive. I am wondering if it just times out? Is the CD to HD transfer so slow that AutoIt thinks that it isn't transfering? IDK. Thanks again for your help Cameronsdad.

-Aaron

EDIT: BTW the msgbox is how i have been testing it and i thought that i had tested all the parts. FYI it doesn't error out right away...It transfers for aprox. 5 mins before it throws my error message in the form of a MsgBox. Thanks again.

Edited by dumdum8684
Link to comment
Share on other sites

Ok did that...I don't see a problem with either the source or the dest. Am i missing something? The program works when i test it with a rather small file (15MB each, 5 files). It also works if i have the files already on the harddrive. I am wondering if it just times out? Is the CD to HD transfer so slow that AutoIt thinks that it isn't transfering? IDK. Thanks again for your help Cameronsdad.

-Aaron

EDIT: BTW the msgbox is how i have been testing it and i thought that i had tested all the parts. FYI it doesn't error out right away...It transfers for aprox. 5 mins before it throws my error message in the form of a MsgBox. Thanks again.

<{POST_SNAPBACK}>

few things...

1) what is the naming schema of the files? the filemask on your browse button is

"*.1", so i made files garbage.1 garbage.2 garbage.3 when i have those msgbox lines above in, it returns source of 'garbage.1.1' which is a non-existant file to use as source.

2) if it's copying for 5 minutes, it seems unlikely to me that it is the filecopy() (the first one) that is causing the error, because if something were going wrong with the filecopy function, it seems like it wouldn't begin to do anything.

Link to comment
Share on other sites

few things...

1) what is the naming schema of the files?  the filemask on your browse button is

"*.1", so i made files garbage.1 garbage.2 garbage.3 when i have those msgbox lines above in, it returns source of 'garbage.1.1' which is a non-existant file to use as source.

2) if it's copying for 5 minutes, it seems unlikely to me that it is the filecopy() (the first one) that is causing the error, because if something were going wrong with the filecopy function, it seems like it wouldn't begin to do anything.

<{POST_SNAPBACK}>

That is because the file names are for example part.exe.1 and part.exe.2 as two of the pieces of the file part.exe. That is why you are getting the error. The file splitter splits them into pieces in the format name.ext.# So that is not the reason that it is erroring out. Like i said it works with smaller files and even those files on a HD to HD transfer but not on a CD to HD transfer (btw the cd is 48x). Sorry that i didn't let you know that earlier.

-Aaron

Link to comment
Share on other sites

That is because the file names are for example part.exe.1 and part.exe.2 as two of the pieces of the file part.exe. That is why you are getting the error. The file splitter splits them into pieces in the format name.ext.# So that is not the reason that it is erroring out. Like i said it works with smaller files and even those files on a HD to HD transfer but not on a CD to HD transfer (btw the cd is 48x). Sorry that i didn't let you know that earlier.

-Aaron

<{POST_SNAPBACK}>

it's cool, i probably should have worked out your concatenations to figure out the schema myself. i'll rename my files so they match what the script is looking for and debug some more.
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...