Jump to content

How to wait for completion of FileCopy


mumdigau
 Share

Recommended Posts

Hi,

I'd like to move files to a temp directory before further processing them. They are quite huge (wav files),and because I experienced that FileCopy is handled asynchronously (i. e, the script does not wait for the copy to be finished), I built a loop which asks for the file size of both source and temp file. The code looks like this:

FileCopy ($inputfile, $tempfile,1)

$filesize = FileGetSize($inputfile)

While 2

Sleep(5)

If FileGetSize($tempfile) = $filesize Then ExitLoop

WEnd

This loops is nested into another loop which goes through all files of the input directory.

The code works fine for some files, but then it loops on the Sleep, so it doesn't get TRUE on the If. When I look into the temp directory, I can't see the temp file. Obviously the FileCopy wasn't successful (why?). So it might be a good idea to check its return value. The question now is: When exactly is the FileCopy return value set? How can I improve the code so it will function as desired?

Many thanks for any help.

Best regards

mumdigau

Link to comment
Share on other sites

  • Developers

Hi,

I'd like to move files to a temp directory before further processing them. They are quite huge (wav files),and because I experienced that FileCopy is handled asynchronously (i. e, the script does not wait for the copy to be finished),

Don't think so. Filecopy is a blocking function and the script will only continue when it is finished.

You can test the returncode to see if he copy was successful.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...