Well, I managed to come up with something (read: dirty hack) that accomplishes what I want. I used an AppleScript and UI scripting through Sikuli. It can and should be heavily improved upon, like, with better error checking and fault-tolerance. I basically had to babysit it as it went through its whole process because every few dozen files it would choke on something. That said, it served my purposes and accomplished my goal.
global theCount
set theCount to 0 as number
tell application "Finder"
set theFolder to choose folder with prompt "Select a directory:"
display dialog "This script will open each QuickTime movie file contained within this folder and its subfolders in QuickTime Player 7, and change the Author attribute to an Artist attribute using the Sikuli IDE. Proceed?"
my processFiles(theFolder)
display dialog (theCount as string) & " files processed."
end tell
on processFiles(theFolder)
tell application "System Events"
set theItems to get the name of every disk item of theFolder
end tell
set theFolder to theFolder as string --do this to concatenate with item name in loop
repeat with i from 1 to length of theItems --this is the loop that works on each file in the current folder
set theItem to item i of theItems
set theItem to (theFolder & theItem) as alias --get a file object
set itemInfo to info for theItem --get the file's info
if visible of itemInfo is true then --only work on invisibles
if folder of itemInfo is false then --and check for folders first or next line will fail
if type identifier of itemInfo is "com.apple.quicktime-movie" then
try --makes this more fault-tolerant
tell application "QuickTime Player 7"
open theItem
end tell
set theCount to theCount + 1
do shell script "java -jar /Applications/Sikuli-IDE.app/Contents/Resources/Java/sikuli-script.jar /Users/username/Desktop/flip\\ to\\ artist\\ source.sikuli" --Sikuli has a better command line interface, but it wasn't working on the current build. This is connecting directly to its java executable, and is REALLY slow as a result.
end try
end if
else if folder of itemInfo is true then
do shell script "touch \"" & POSIX path of theItem & "\"" --do this to track the progress of the script based on folder modification date
my processFiles(theItem) --operate recursively until all files are processed
end if
end if
end repeat
end processFiles
The Sikuli script is essentially:
switchApp("QuickTime Player 7")
keyDown(Key.CMD)
type("j")
keyUp(Key.CMD)
click([Author annotation tag])
click([Artist option])
keyDown(Key.CMD)
type("s")
keyUp(Key.CMD)
keyDown(Key.CMD)
type("w")
keyUp(Key.CMD)
keyDown(Key.CMD)
type("w")
keyUp(Key.CMD)
waitVanish([a QuickTime window])
I'm not an experienced Sikuli developer, but almost certainly the key presses should be put into the AppleScript as UI actions. That part's not hard. It's the clicking of choices that's hard. The AppleScript could also check for the Author attribute; that stuff is documented in the AppleScript dictionary, but the property is read-only.
Have you tried comparing a file before/after the change? Maybe it's simpler to do through editing the binary movie file directly... – Daniel Beck – 2011-09-04T07:35:14.220
Hm! I've never done that before, but at first glance it does appear to be a replacement of
aut
withART
right at the tail end of the binary file. – NReilingh – 2011-09-04T09:04:04.150You could also try to add all these files to an iTunes library, and use its metadata editor to change all files at once. – Daniel Beck – 2011-09-04T09:20:01.723
@Daniel Could you elaborate? iTunes definitely is part of the equation here, as these files only contain an audio track. The issue is that I can't pick up the Author tag at all in iTunes. Am I totally missing what this "metadata editor" is? – NReilingh – 2011-09-04T09:54:53.177
No, you're right. Unfortunately, I have neither a file like this nor QT7 Pro available right now, so I can't experiment myself. – Daniel Beck – 2011-09-04T10:30:26.587
@Daniel Well, I was going to attach a bounty to this when it passed the age threshold, but I ended up implementing a method using AppleScript and Sikuli (since I'm just not going anywhere near AppleScript UI scripting). It's slow as ALL HECK as a result, but at least I'm not doing it. – NReilingh – 2011-09-05T22:36:09.127
Could you post that? Sounds,,, interesting :) – Daniel Beck – 2011-09-06T05:25:14.087
@Daniel Bam. Check it out. :P
– NReilingh – 2011-09-07T04:55:28.913Interesting. I have never worked with Sikuli except trying to find out whether I can use it to game Word of Warcraft, and there were no UI elements to click. One advantage is definitely its brevity compared to AppleScript. – Daniel Beck – 2011-09-07T05:14:07.613
@Daniel. That's for sure. And it operates using screen shots, so one could theoretically script anything a human can do through a GUI. – NReilingh – 2011-09-07T05:40:48.760