QuickTime X – AppleScript Automation Guide

applescriptautomatormacosquicktime

(Copying this from Stack Overflow, because this might be a better place to ask)

Looking for help (really to do) with a script/automator action for opening a files in QT X and using the export 720p command. I do not want to use the encode feature built into the finder. Using the "export" feature in QT X with the files I'm working does the trick and does not re-encode the files. I tried using automator but there is no "export" action only "encode" which re-encodes the files.

I see the command in the dictionary but can't seem to make it work.

I've started with this but I keep getting a permissions problem. A guy on Stack Overflow has noted the same problem.

tell application "Finder"
set savePath to "Macintosh HD:Users:WBTVPOST:Desktop"
end tell

tell application "QuickTime Player"
activate
tell application "QuickTime Player" to get the name of front window
set vidName to name
export (document 1) in savePath using settings preset "720p"
end tell

I've seen a lot of scripting help but mostly for QT 7 and Pro. Not so much for X

Is this possible?

Thanks in advance for your talent and skill,

Cheers!

Best Answer

tell application "QuickTime Player"
    set movieName to the name of the front document
    set savePath to a reference to POSIX file ¬
        ("/Users/WBTVPOST/Desktop/" & movieName & ".mov")
    export the front document in savePath using settings preset "720p"
end tell

System info: AppleScript version: 2.7 System version: 10.13.6

PS. User @wowfunhappy is absolutely correct in saying that the export command does re-encode a file. It has to in order to apply whatever settings are contained within the preset.