How to determine when a watched folder copy is complete?

I actually found a way to get this working. I set two variables (OldSize and NewSize). OldSize is set to -3 (just to make sure it doesn't match any real values) to begin, and NewSize is set to the value of this shell command:

du -s $KMVAR_NewAppPath | egrep -Eo '\d+'

That returns the size of the app bundle, and it's constantly growing as it's copied. Once both values are set, I enter a loop that sets OldSize to NewSize, then recalculates NewSize, and pauses a very brief amount of time. The loop exits when both values are equal, which only happens after Finder has finished copying the files.

Once the loop exits, the macro continues, and I know that I'm working with the full final app. It may not be pretty, but it works!

-rob.

3 Likes