Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

akadmon

Suspended
Original poster
Aug 30, 2006
2,006
2
New England
Can anyone point me to an script that closes an application at a certain time and saves the active file? I'm in the process of digitizing my hi 8 video library and I often find myself wishing I could tell iMovie to quit 2 hours after starting the conversion (i.e. at the end of the tape) so that I don't have to be babysitting the whole process. Without this iMovie will continue filling up the hard drive space even after the tape ends, unless I manually stop the import. I'm sure this is a very simple thing to do in AppleScript, but I have no clue how to do this, since I've never used AS. I would appreciate some help here.
 

numero

macrumors regular
Jul 23, 2002
106
3
OR
Give this a try. Start your tape and then launch this script.

iMovie HD isn't scriptable, but you can get some stuff done by calling it to the front and issuing key commands. Since your project already has a name and location, all you have to do it get it to save. You may need more than a 5 second delay between the save and the quit. I didn't actually try this with a capture session active. You may also want to capture for slightly more than 2 hours.

Let me know how this works out.

-numero




Code:
-- 60 seconds * 60 minutes * 2 hours
delay 60 * 60 * 2

tell application "iMovie HD"
	activate
end tell

tell application "System Events"
	keystroke "s" using command down
	delay 5
	keystroke "q" using command down
end tell
 

akadmon

Suspended
Original poster
Aug 30, 2006
2,006
2
New England
Give this a try. Start your tape and then launch this script.

iMovie HD isn't scriptable, but you can get some stuff done by calling it to the front and issuing key commands. Since your project already has a name and location, all you have to do it get it to save. You may need more than a 5 second delay between the save and the quit. I didn't actually try this with a capture session active. You may also want to capture for slightly more than 2 hours.

Let me know how this works out.


OK, thanks. I'll try this when I get home.
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
Western US
What is it with Apple having such poor AppleScript support in their own applications? It doesn't set a very good example. Aren't they embarrassed by the richness of AppleScript dictionaries of, for example, Adobe apps? Even many inexpensive shareware apps put Apple's own apps to shame in terms of AppleScript support. Especially the pro apps, where people really need to use batch processing and automation.
 

akadmon

Suspended
Original poster
Aug 30, 2006
2,006
2
New England
OK, thanks. I'll try this when I get home.

I tried it and it works, but I had to modify it a little, since issuing the :apple:+s commad brings up a Do you want to save changes to... dialog, which requires a yes answer in order to allow iMovie to quit. Here is the modified script

Code:
-- 60 seconds * 60 minutes * 2 hours
delay 60 * 60 * 2

tell application "iMovie HD"
	activate
end tell

tell application "System Events"
	keystroke "s" using command down
	delay 5
	keystroke "q" using command down
	delay 5
	keystroke "enter"
end tell

Thanks a bunch! :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.