Jump to content
Sign in to follow this  
Steven Meier

Help with copy and log file output.

Recommended Posts

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.



Share this post

Link to post
Share on other sites

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")

edit: I forgot to add the ")"

Edited by vollyman

Share this post

Link to post
Share on other sites

FileCopy does not support @error

Simply treat the condition as a boolean.

If Not FileCopy("Filecopy", "FileDest") Then
    MsgBox(0, '', 'FileCopy Failed')

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?

Share this post

Link to post
Share on other sites

From the help file:

FileCopy Copies one or more files.

FileCopy ( "source", "dest" [, flag] )


source 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 files

1 = overwrite existing files

8 = Create destination directory structure if it doesn't exist (See Remarks).

Return Value

Success: 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")
    MsgBox(4096, "Result", $result)

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
    Return $dividend / $divisor
Edited by vollyman

Share this post

Link to post
Share on other sites

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.



Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...