Steven Meier Posted July 28, 2006 Posted July 28, 2006 I am very new to autoit but am very impressed. What I am trying to do is a basic copy from a static directory on local users lappys and copy files from this location to a server location. I have the copy using dircopy working great, the problem I have is checking if the copy has worked fine and spitting out a message saying copy complete or an error if it fails. If possible I would like to create a little log file maybe with file names or number of files and directorys copied. Help as I am lost on this. Cheers Steve
Bert Posted July 28, 2006 Posted July 28, 2006 (edited) you could do a fileexist on the server after the copy is done. A second method is this example: $copy = filecopy("Filecopy", "FileDest") if @error then msgbox(0, "ERROR", "file not copied") endif edit: I forgot to add the ")" Edited July 28, 2006 by vollyman The Vollatran project My blog: http://www.vollysinterestingshit.com/
MHz Posted July 28, 2006 Posted July 28, 2006 FileCopy does not support @error Simply treat the condition as a boolean. If Not FileCopy("Filecopy", "FileDest") Then MsgBox(0, '', 'FileCopy Failed') EndIf The logfile of files? is too vague of a question to respond to i.e. Are you refering to a wildcard FileCopy to check files copied?
Bert Posted July 28, 2006 Posted July 28, 2006 (edited) From the help file:FileCopy Copies one or more files.FileCopy ( "source", "dest" [, flag] )Parameterssource The source path of the file(s) to copy. Wildcards are supported. dest The destination path of the copied file(s). flag [optional] this flag determines whether to overwrite files if they already exist.Can be a combination of the following:0 = (default) do not overwrite existing files1 = overwrite existing files8 = Create destination directory structure if it doesn't exist (See Remarks). Return ValueSuccess: Returns 1. Failure: Returns 0.----------------------------------------It gives a return value. I thought that could be used for a error detection.edit: In thinking about it, I see what you mean. I don't use @error hardly at all so what I should have done is what you suggested. I further reading the help file, I see what you are talking about.$result = myDiv(5, 0) If @error Then MsgBox(4096,"Error", "Division by Zero") Else MsgBox(4096, "Result", $result) EndIf Exit Func myDiv($dividend, $divisor) If $dividend = 0 And $divisor = 0 Then SetError(2) ;indeterminate form 0/0 ElseIf $divisor = 0 Then SetError(1) ;plain division by zero EndIf Return $dividend / $divisor EndFunc Edited July 28, 2006 by vollyman The Vollatran project My blog: http://www.vollysinterestingshit.com/
Brooks Betts Posted August 16, 2006 Posted August 16, 2006 Hey All, Admittedly I am very new to AutoIt as well. This post is the closest I have seen to grabbing a logfile for a filecopy. It appears that the original post was okay with error handling, but I want to get a logfile for historical reasons. Has anyone done this? I want to copy files from a local hard drive to a server and log anything I can about that copy. Filename, date, time, etc. I can do this in CMD file if I have to, but it would be so much cleaner in this script. Thanks, Brooks
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