Tag tracks in iTunes with Quicksilver

Sep 02, '08 07:30:04AM

Contributed by: jedverity

I came up with the following method of 'tagging' tracks in iTunes using Quicksilver -- Quick Tag was a good app for this kind of thing, but it doesn't work with iTunes 7.7.1, and it's nice to not have to download another application when Quicksilver can handle part of its functionality.

  1. Open Script Editor (in Applications » Utilities), and paste the code below into a new script:
    property tag_prefix : "<"
    property tag_suffix : ">"
    
    using terms from application "Quicksilver"
       on process text txt
           set txt_items to my itemize(txt, " ")
           set tags to my wrap(txt_items)
           tell application "iTunes"
               set t to current track
               set g to t's grouping
               if g ≠ "" then
                   set tags to my compare(g, tags)
                   set g to g & " "
               end if
    
               set t's grouping to g & my itemize(tags, "")
           end tell
       end process text
    end using terms from
    
    to itemize(var, delim)
       set delims_old to AppleScript's text item delimiters
       set AppleScript's text item delimiters to delim
       if var's class = list then
           set txt to var as text
       else
           set txt to var's text items
       end if
       set AppleScript's text item delimiters to delims_old
       return txt
    end itemize
    
    to compare(tags_old, tags_new)
       set tags to {}
       repeat with i in tags_new
           if offset of i in tags_old = 0 then
               set end of tags to i
           end if
       end repeat
       return tags
    end compare
    
    to wrap(array)
       set output to {}
       repeat with i in array
           set end of output to (tag_prefix & i & tag_suffix) as string
       end repeat
       return output
    end wrap
  2. Save your script as Tag Track (or whatever you want to call it) in ~/Library » Application Support » Quicksilver » Actions.
  3. Restart Quicksilver.
  4. While iTunes is playing, invoke Quicksilver, hit the period key, to go into text mode. Now type your tags separated by spaces, and choose Tag Track from the actions in the next pane. (Or you can do Tag Track in the first pane...).
Note: Tags are saved like this: <tag_word> in the Groupings field. To create a playlist based on tags, use a rule of "Grouping -- contains -- <tag_word>".

[robg adds: I haven't tested this one.]

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20080829093323909