Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Tag tracks in iTunes with Quicksilver Apps
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.]
    •    
  • Currently 3.00 / 5
  You rated: 5 / 5 (4 votes cast)
 
[9,781 views]  

Tag tracks in iTunes with Quicksilver | 7 comments | Create New Account
Click here to return to the 'Tag tracks in iTunes with Quicksilver' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Tag tracks in iTunes with Quicksilver
Authored by: tjarrett on Sep 02, '08 08:18:24AM

Looking at the source, it looks like the script will insert tags into the "Grouping" field. While this will work for most tracks, it's not a good idea on classical tracks, where "Grouping" usually captures the overall piece name and the track title is the movement title.

For this and a jillion other reasons, I wish Apple or the MP3 tagging folks would go ahead and define a new tags frame for music file metadata. It would make it much easier to do tagging without repurposing/misusing existing fields.



[ Reply to This | # ]
Tag tracks in iTunes with Quicksilver
Authored by: jedverity on Sep 02, '08 11:26:15AM

You're right -- it's a shame there isn't an explicit tag field.

It might be better to put tags in the Comments field, but Groupings features auto-complete, which is handy for some uses. If anyone wants a version of the script that puts tags in the Comments field or that gives you the option to specify one or the other easily, email me at junk[ at ]veritys[ . ]com.



[ Reply to This | # ]
Tag tracks in iTunes with Quicksilver
Authored by: S on Sep 02, '08 08:35:47AM

Script editor is in /Applications/AppleScript, not /Applications/Utilities.



[ Reply to This | # ]
Tag tracks in iTunes with Quicksilver
Authored by: Volt on Sep 02, '08 08:12:04PM
I've been using TuneTag by Chris Brown for a couple years now, which does something similar with the Comments field (with a tag being *tag_word). The site is supposed to be here, but it no longer works. It's licensed under Creative Commons (by-nc-sa) though, so I zipped it up here. Extract the scripts to ~/Library/Application Support/Quicksilver/Actions/, and it works the same way as the tip. tag tags the current song, tagselected tags any songs you select in iTunes, and playtag plays whatever tag you typed in. Tags are separated by a space.

Not to discount the tip here, but I've used this for a while and like it, so I just feel it could be useful to provide another (similar) option.

[ Reply to This | # ]

Tag tracks in iTunes with Quicksilver
Authored by: joestalin on Sep 03, '08 06:43:19AM

This doesn't seem to work if the Grouping field is already populated.



[ Reply to This | # ]
Correction: Tag tracks in iTunes with Quicksilver
Authored by: jedverity on Sep 04, '08 12:19:07PM
Sorry for the grouping issue (from the last reply). Here is the corrected script:
property tag_prefix : ""

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)
			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
		set o to offset of i in tags_old
		if o = 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
       set end of output to (tag_prefix & i & tag_suffix) as string
   end repeat
   return output
end wrap


[ Reply to This | # ]
Correction: Tag tracks in iTunes with Quicksilver
Authored by: jedverity on Sep 04, '08 12:21:08PM
The last post got screwy. Here is the proper code:

property tag_prefix : ""

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)
			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
		set o to offset of i in tags_old
		if o = 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


[ Reply to This | # ]