quicktime - wait until finish

Hey all,

HOpe someone could provide the following snippet.

overview

  • doing some changes to a quicktime file
  • saving changes to the file (100+ files)

goal

  • have the applescript wait until the file is saved before going forward with the next line of code.

thanks.

Try to adapt this:

tell application "QuickTime Player"
	--loop thru all your videos
	set allvids to every document
	repeat with a in allvids
		tell a
			--wait 
			do shell script "sleep 4"
			repeat
				try
					play
				end try
				
				if playing is true then exit repeat
			end repeat
			--do whatever you want  
			present
		end tell
	end repeat
end tell


Thanks Joy.

I’ll take a look at it. Appreciate the response.

Your question was too generic to help you further. I added only the loop handler to my original script, to help you understand how to apply actions in batch.

Note that you’ve to put the

do shell script "sleep 4"

command inside the repeat handler, to check every 4 seconds if a progress was made.
Furthermore, try this:

if modified of document 1 is true then exit repeat

.always inside the repeat handler.
Hope this helps.

Thanks for this. This worked great. one issue was.

issue

  • file can be still played if it is being “saved” which BREAKS the script

question:

  • is there a way to check if the file is being saved?

Hello.

You can check if the file is being busy, and if the file size changes within intervals of say two seconds.

The second method being more reliable than the first one.

thanks everyone. working code.


set myFolder to (choose folder) as alias -- use the path to the folder that's loading
set firstSize to size of (info for myFolder) --get initial size
delay 10 --wait 3 seconds
set newSize to size of (info for myFolder) --get a newer size, bigger
repeat while newSize ≠ firstSize --if they don't equal, loop until they do
	set firstSize to newSize --new base size
	delay 10 --wait three seconds
	set newSize to size of (info for myFolder) --get a newer size
end repeat --once the sizes match, the transfer is complete