Sign in to follow this  
Followers 0
mumdigau

How to wait for completion of FileCopy

3 posts in this topic

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

Share this post


Link to post
Share on other sites



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.


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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.

You're right. Checking the retun value will do the thing. Thanks.

mumdigau

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  
Followers 0