Jump to content

Recommended Posts

Posted

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

Posted

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?

Posted (edited)

From the help file:

FileCopy Copies one or more files.

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

Parameters

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")
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 by vollyman
  • 3 weeks later...
Posted

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

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
×
×
  • Create New...