How do I make my script wait until exporting is done? I have most of my script working now. It will cut a sound file into three segments in quicktime but after I start exporting the first segment into MPEG4, the rest of the script times out. I want the script to wait on each export so that I can export all three.
Maybe you can add a repeat loop, after the export command, that uses the Finder to check every x seconds to see when the size of the exported file stops changing. Or maybe you need only to increase the timeout.
with timeout of 600 seconds
-- export stuff
end timeout
According to the Dictionary, Nope :?
From the QuickTime Pro Dictionary:
Here is how I use this snippet:
on process_item(this_item)
try
tell application "QuickTime Player"
activate
--set show movie info window to true
--close when done
if window named "Untitled 1" exists then
close window named "Untitled 1"
end if
--my toggle_suppress(true)
open this_item
set position of window 1 to {2, 20}
try
--play movie 1
--Used to add leading zero's, and count number of item to the filename
set new_file to (_Destination & my add_leading_zeros(item_counter, 2) & ".mp4") as string
export movie 1 to file new_file as MPEG4 using default settings with replacing
close movie 1
set item_counter to item_counter + 1
--play movie 1
on error errMsg number errNum from errFrom partial result errResult to errTo
if errNum is not -128 then
activate
display dialog errNum buttons {"OK"} default button 1
end if
error number -128
end try
try
repeat
if done of movie 1 is true then
exit repeat
else
delay 3
end if
end repeat
set current time of movie 1 to 18000
close movie 1
end try
end tell
on error errMsg number errNum from errFrom partial result errResult to errTo
-- on error code goes here
my toggle_suppress(false)
if errNum is not -128 then
activate
display dialog errNum buttons {"OK"} default button 1
end if
error number -128
end try
end process_item
So I guess just using the timeout would be better and proper.
There ought to be a way to check if a task is completed in applescript to keep it from giving a timeout error?
Any ideas?
I’d rather not use the timeout method since I want this to be somewhat automated and am not sure I can put a definitive time on the exportation of the file. That is why I would rather have the script to keep checking if the the export is complete or not before continuing on.
Maybe I could set a variable at the begining of the loop and check the variable at the end of the loop? But that does not seem like it would work either since the next line of the code can not be read.
If the timeout is set to 600 seconds and it takes only 200 seconds to complete a task, the script will move on to the next step after 200 seconds. Every command has a default timeout interval and this simply lengthens it for operations that cannot be completed within the default amount of time.