SBROOKJR Posted October 27, 2006 Share Posted October 27, 2006 HI, I'm new to autoit. I've created two simple scripts to copy documents from a file server and vice versa. I would like to create a error handler to display a message box telling me if the files were successfully copied or if it failed. Any help would be appreciated. thanks. Steveb Link to comment Share on other sites More sharing options...
BigDod Posted October 27, 2006 Share Posted October 27, 2006 (edited) Wrong place, should be in support. EDIT: moved to support by Larry Edited October 27, 2006 by Larry Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
MHz Posted October 27, 2006 Share Posted October 27, 2006 Check if the condition is true with the copy. If FileCopy('source', 'destination') Then MsgBox(0x40000, '', 'File copied') Else MsgBox(0x40000, '', 'File copy failed') EndIf Link to comment Share on other sites More sharing options...
SBROOKJR Posted October 27, 2006 Author Share Posted October 27, 2006 thanks for the quick response. I added the code but I get a file copy failed even though the file did appear to copy. This is my code: FILECOPY("C:\MYDOCS\*.*", "C:\test\MyDocs\", 1) If FileCopy('source', 'destination') Then MsgBox(0x40000, '', 'File copied') Else MsgBox(0x40000, '', 'File copy failed') EndIf Check if the condition is true with the copy. If FileCopy('source', 'destination') Then MsgBox(0x40000, '', 'File copied') Else MsgBox(0x40000, '', 'File copy failed') EndIf Link to comment Share on other sites More sharing options...
BigDod Posted October 27, 2006 Share Posted October 27, 2006 The reason that it says it failed is because you are trying to copy twice. Loose the first line of your script and it will work. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
SBROOKJR Posted October 27, 2006 Author Share Posted October 27, 2006 My bad. Its working now. I really appreciate your help. thanks.The reason that it says it failed is because you are trying to copy twice. Loose the first line of your script and it will work. Link to comment Share on other sites More sharing options...
MHz Posted October 27, 2006 Share Posted October 27, 2006 Since you are using a wildcard for the source, then you may want to have a look at using FileFindFirstFile() & FileFindNextFile() for checking each file copied for precise error results. Link to comment Share on other sites More sharing options...
SBROOKJR Posted October 27, 2006 Author Share Posted October 27, 2006 How would I go about doing that? Would there be a way to add a status indicator?Since you are using a wildcard for the source, then you may want to have a look at using FileFindFirstFile() & FileFindNextFile() for checking each file copied for precise error results. Link to comment Share on other sites More sharing options...
Valuater Posted October 27, 2006 Share Posted October 27, 2006 search "copy with progress" in scripts and scraps, there are many to choose from 8) Link to comment Share on other sites More sharing options...
MHz Posted October 27, 2006 Share Posted October 27, 2006 Example $path = 'C:\MYDOCS' $handle_search = FileFindFirstFile($path & '\*.*') If $handle_search <> -1 Then While 1 $file_found = FileFindNextFile($handle_search) If @error Then ExitLoop If StringInStr(FileGetAttrib($file_found), 'D') Then ContinueLoop EndIf If Not FileCopy($path & '\' & $file_found, 'C:\test\MyDocs\') Then MsgBox(0x40000, '', 'File copy error with ' & $path & '\' & $file_found) EndIf WEnd FileClose($handle_search) Else MsgBox(0x40000, '', 'Failed to open search handle') EndIf Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now