dougscripts.com

December 3 2019 - 1:22 am

That Category Tag

When iTunes was ka-blammed into the Media apps, I thought it was interesting to see how track tags were re-assigned. Obviously, tags like Season, Show and Episode ID are TV app-centric so they were removed from the Music app. Similarly, the Album and Album Artist tags do not appear for TV Shows or Movies in the TV app. And so on.

So I guess Category has always been a Music-centric tag. I knew that it was used by Podcast tracks, but I've recently noticed that some of my radio stream tracks (originally dragged from Radio Stations in iTunes) also use it. Wouldn't it be useful to put the Category tag into service as a secondary Genre tag, or what have you?

But there's no easy way to access the Category tag. It doesn't appear in a track's Info panel. I'm pretty sure it isn't written to its file's metadata. And although the Category column can still be seen in Songs View, Category tags can't be edited there either, like a cell in a table, as other tags can be.

Happily, our benefactors at Apple have kept the AppleScript category property available. Here is a script that will allow you to view and/or edit the Category tags of the selected tracks in the Music app:

use AppleScript version "2.7" -- Mojave (10.14) or later

use framework "Foundation"

use scripting additions

property defaultMixed : "*mixed"

on run

tell application "Music"

set selectedTracks to a reference to selection

set numberSelected to (count of selectedTracks)

if numberSelected is 0 then return

if numberSelected is 1 then

set defaultAnswer to (get category of item 1 of selectedTracks)

else

set defaultAnswer to my distillList(category of selectedTracks)

end if

set s to "s"

if numberSelected is 1 then set s to ""

try

set editOpts to (display dialog (numberSelected & " track" & s & " selected." & return & return & "Category:") as text default answer defaultAnswer buttons {"Cancel", "Apply"} default button 2 with title "Edit Category Tag" with icon 1)

on error

return

end try

if text returned of editOpts is defaultMixed then return

try

set category of selectedTracks to text returned of editOpts

end try

end tell

end run

on distillList(alist)

tell current application's NSSet to set theSet to alloc()'s initWithArray:alist

if theSet's |count|() as integer is 1 then return (theSet's anyObject()) as text

return defaultMixed

end distillList

This script can be opened and saved in the Script Editor app on your computer by clicking the small script icon above and acceding to the gauntlet of security-related prompts that appear. Save it named whatever you like using the Format "Script" in your [username]/Library/Music/Scripts/ folder so that it appears in the Music app's Script menu.

To use it, select one or more tracks in the Music app and then select the script from the Script menu.

Site contents © 2001 - 2019 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not interrupt the one doing it.