Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have about 1,700 QuickTime movie files (some have .mov extension, most do not; it's not important, all are seen by the system as "QuickTime movie" and that's what they are) in an organized folder structure.

Using QuickTime Pro 7, I can view the file's Properties and see a set of metadata, which it calls "Annotations". One of these annotations is an "Author" tag. I need to flip that annotation over to an "Artist" tag, while preserving the data within.

QuickTime Pro Properties

... for each of these 1,700-odd files.

What is the best option and implementation for automating this?

My hunch is that an AppleScript could be easily designed that just traverses the contents of this folder structure looking for files of this type, and then making the switch, but my AppleScript-fu is no good.

share|improve this question
    
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 Sep 4 '11 at 7:35
    
Hm! I've never done that before, but at first glance it does appear to be a replacement of aut with ART right at the tail end of the binary file. –  NReilingh Sep 4 '11 at 9:04
    
You 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 Sep 4 '11 at 9:20
    
@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 Sep 4 '11 at 9:54
    
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 Sep 4 '11 at 10:30
show 5 more comments

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.