Wait until finished copying files to mounted volume

I am currently working on a script to upload hi-res images and also convert them to a lo-res version and save them on a server volume. The script works fine except when the hi-res files are numerous and it takes a while for them to be copied to the server.

The problem I have is how to make the script wait for the upload of the hi-res files before preceeding to the next task without timing out? Is there a “wait for idle” or something that will do this for me without inserting a very long delay?

I would need to put the “wait” after the script starts duplicating the files to the remote volumes. Thanks for any help. Here is the script:


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]