dougscripts.com

February 26 2017 - 8:37 am

How to Blankety-Blank Blank

As you may have noticed, the last few versions of iTunes have been gradually "contextualizing" the interface. For example, the Info window will only display the kind-pertinent tags for a selected track. (Remember: it used to be that the Info window displayed the same configuration for any track; so that Music tracks had access to TV-kind tags, like Season and Episode ID, and so on.)

Despite this, when the iTunes browser window is in Songs view, non-contextual tags can still be displayed and tracks can still be sorted using them. This is because every track entry in the database has the same columns whether they are used for that kind of track or not. Thus, for example, Music tracks have "season" and "episode ID" track tags even though they are not used for Music tracks.

AppleScript can access these tags and a script of mine, Sort by Artwork Size, can store the dimensions of a track's artwork (eg, "600x600") to the Category or Episode ID tag. Tracks can then be sorted by their "artwork size" or those tags can be used when constructing Smart playlist criteria.

However, since these tags can't be accessed very easily it is a chore to clear them if they are no longer required. So here's a script that will blank a particular tag of all the selected tracks. In this case, it blanks the episode ID tag. For people who already know how to script such a thing, this will be easy as pie. But, if your skill level as a scripter is below Dabbler, you may want to use this as a template for your own blanking scripts:

tell application "iTunes"

try

set sel to selection of front browser window

if sel is {} then error

on error

try

display dialog "Select some tracks first." buttons {"OK"} default button 1

end try

return

end try

repeat with aTrack in sel

try

set aTrack's episode ID to ""

-- or, 0 if a number value, false if a boolean value

end try

end repeat

end tell

Click on the little AppleScript icon above to open the script in Script Editor at your house—don't copy the text in the browser.

The first block of the script checks for selected tracks and if nothing is selected it will dismiss itself. Then, in the next block, it simply tries to set the episode ID property of each selected track to empty text.

Track tags can contain text, number or boolean values. To see how to deal with any particular track property, look up track in the iTunes scripting definition file: in Script Editor, click Window > Library and in the panel that appears double-click "iTunes" in the list and scroll the window that appears until you get to the track properties in the "iTunes Suite".

Site contents © 2001 - 2024 (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 be interrupting the one who is doing it.