Pages

Friday, 27 May 2005

Update: Adding movies to iTunes for Tiger

Here is an Automator workflow (why not?) which converts movies into
QuickTime Media Link documents and then imports them into iTunes 4.8.

This is an update to the earlier hint which didn't work in Tiger.





  1. Create a new Automator workflow by opening Automator.

  2. Add an "Ask for Finder Items" action, type Files, and tick the Allow
    Multiple Selection box.

  3. Add a "Run AppleScript" action. The script box should be edited to match
    the below script:


    on run {input, parameters}
    set itemno to 1
    repeat (count of input) times
    set str1 to POSIX path of (item itemno of input)
    set str2 to ""
    set charno to 1
    repeat (length of str1) times
    if (character charno of str1 is equal to character 1 of " ")
    then
    set str2 to (str2 & "%20") as string
    else
    set str2 to (str2 & character charno of str1) as string
    end if
    set charno to (charno + 1)
    end repeat
    set astring to {"<?xml version=\"1.0\"?><?quicktime
    type=\"application/x-quicktime-media-link\"?><embed src=\"file://localhost"
    & str2 & "\" />"} as string
    set afile to open for access (((item itemno of input) as string) &
    ".mov") with write permission
    write astring to afile as string
    close access afile
    set mfile to alias (((item itemno of input) as string) & ".mov")
    tell application "iTunes"
    add mfile
    end tell
    set itemno to (itemno + 1)
    end repeat
    end run

  4. Run the workflow. Select your movie files and they should get imported
    into iTunes.

There are some limitations to this approach. I'm converting the file name to
a URL and the only character I'm fixing is the space. If your files contain
other special characters that can't occur in URLs, you'll have to rename
them or edit the script above. And in my opinion, while there is a lack of
useful actions, Automator is only slightly better than using AppleScript
directly.


No comments:

Post a Comment