dougscripts.com

February 2 2014 - 8:17 am

Disc 1 of 1

A Corespondent laments:

My personal preference when dealing with the disc count field (1 of 2, etc) is to leave it blank for single CD albums instead of tagging them as "1 of 1." There is something about 1 of 1 that just bugs me so I try to clear those out. Can you think of anything you have that can search in those fields? Sorting the library by disc number [is an unsatisfactory solution] because every disc 1—regardless if there is a second disc—gets sorted.

Yeah. It would be easy to do a Multi-Item edit on these guys if you could only corral 'em all together somehow. But: sorting by Disc # sorts by Disc Number alone and ignores the Disc Count so the "1 of 1" tracks are not necessarily sorted together; rather, they're sorted by Album (all the Disc 1 albums A-Z, followed by all the Disc 2 albums A-Z, and so on). Smart Playlists are of little use to gather up these tracks since Disc Count is not a smart criterion.

So here's a script that will look at each track in a selection or all the tracks in the selected playlist; if the track's Disc Count is 1 the script will set it to 0, effectively blanking it:

tell application id "com.apple.iTunes"

set thePlaylist to (get view of front window)

set sel to selection

if sel is {} then

# all tracks in playlist

repeat with i from 1 to (get index of last track of thePlaylist)

my processTheTrack(track i of thePlaylist)

end repeat

else

# selected tracks

repeat with i from 1 to (length of sel)

my processTheTrack(item i of sel)

end repeat

end if

end tell

to processTheTrack(t)

tell application id "com.apple.iTunes"

try

if disc count of t is 1 then set disc count of t to 0

end try

end tell

end processTheTrack

You can save that in AppleScript Editor named whatever you like and using "Script" as the file format to your ~/Library/iTunes/Scripts/ folder whereupon it will appear in the iTunes Scripts menu.

The script iterates through each track individually, so if you run it against your entire Music library playlist you'll have time to file nails, tidy bookshelves, re-string guitar, or perform some other menial task.

UPDATE: To eliminate the disc number as well (although I prefer to keep it) change the handler to this:

to processTheTrack(t)

tell application id "com.apple.iTunes"

try

if disc count of t is 1 then

set disc number of t to 0

set disc count of t to 0

end if

end try

end tell

end processTheTrack

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.