Cleaning iTunes
Pages: 1, 2
A Little AppleScript to the Rescue
I wrote a little AppleScript to grab the selected tracks in the playlist, grab the "name" of the first track in the selection, and use that for the name of the remaining tracks. I need to be careful here -- depending on which way I have the playlist ordered (ascending or descending in a certain column), the first track may be different than what I see as the first track in the window.
This is a quick script to prove to myself that this idea will work. I do not want to get too deep into a problem before I find out if it is not going to work.
tell application "iTunes"
set myWindow to browser window 1
set mySelection to selection of myWindow
set myNewName to name of first item in (get the selection of browser window 1)
repeat with myTrack in (get the selection of browser window 1)
set name of myTrack to myNewName
end repeat
end tell
I used this little script for a couple of CDs, and messed up a couple of times because the right name did not end up in myNewName. I added a dialog to allow me to choose the correct track name from all of the selected tracks, and another dialog to confirm the selection and give me a chance to edit it.
tell application "iTunes"
set myNames to name of selection of browser window 1
set myNewName to choose from list myNames with prompt "Which name?" multiple selections allowed 0
if myNewName is false then --nothing selected, just stop
return
end if
display dialog "Use this name?" default answer myNewName buttons {"Cancel", "Ok"} default button 1 with icon 1 giving up after 5
if the button returned of the result is "Cancel" then
return
end if
repeat with myTrack in (get the selection of browser window 1)
set name of myTrack to myNewName
end repeat
end tell
After I use this script, the track names should be half-right. I still need to combine them with the string in the artist portion. I do this a bit differently, so I do not need to select tracks, since I want to change all tracks in the playlist at the same time -- I easily create temporary playlists by dragging a group of selected tracks into the playlist window. Once I have those tracks isolated in their own playlist, I have an easier time working with them, even if I de-select them. I tell iTunes to cycle through all of the tracks, join the name and artist strings with a ", ", then set the name to the combined string. Once the string in the artist section is safely in the track name, I set the artist string to the real artist, which for me means the performer (iTunes has a separate column for Composer -- see the "Edit -> View Options..." menu item to see how you can change the columns in iTunes).
|
|
tell application "iTunes"
set myPlaylist to playlist "To Do"
repeat with i from 1 to count of tracks of myPlaylist
set myTrack to track i of myPlaylist
set myArtist to artist of myTrack
set myName to name of myTrack
set myNewName to myName & ", " & myArtist
set name of myTrack to myArtist
set artist of myTrack to "Glenn Gould"
end repeat
end tell
Once I have the basic idea of the script to combine the artist and track names, I fill out the script with dialogs to select the playlist and the artist name so I do not have to change the script for every group of changes that I want to make.
|
|
tell application "iTunes"
set allPlaylists to name of user playlists
set myPlaylist to choose from list allPlaylists with prompt
"Which playlist?" multiple selections allowed 0
if myPlaylist is false then --nothing selected, just stop
return
end if
display dialog "What is the new artist name?" default answer "Glenn Gould" buttons {"Cancel", "Ok"} default button 1 with icon 1 giving up after 5
if the button returned of the result is "Cancel" then
return
end if
repeat with i from 1 to count of tracks of myPlaylist
set myTrack to track i of myPlaylist
set myArtist to artist of myTrack
set myName to name of myTrack
set myNewName to myName & ", " & myArtist
set name of myTrack to myArtist
set artist of myTrack to "Glenn Gould"
end repeat
end tell
Once I get the scripts just how I like them, I add them to the iTunes Scripts directory (/Users/user-name/Library/iTunes/Scripts), which I had to create myself since it did not exist. When iTunes recognizes the directory, an AppleScript icon shows up to the left of the Help menu, and the names of the scripts in the directory show up in the Scripts menu, ready for use.
|
|
Wrapping Up
In a short time, I created two scripts that clean up quite a bit of classical music information in my iTunes Music Library. AppleScript gives me easy access to almost everything that iTunes knows, and lets me automate repetitive tasks. Other problems that I need to fix are special cases or different situations, so I create other scripts for them, first trying very small scripts to make sure the idea works, then adapting the small script for general use. Very quickly I have a powerful set of tools to fix most of the problems I find in my MP3 files without having to do a lot of typing. Now I can spend time listening to my music rather than categorizing it.
brian d foy is a Perl trainer for Stonehenge Consulting Services and is the publisher of The Perl Review.
Return to the Mac DevCenter.
- Trackback from http://radio.weblogs.com/0108247/2003/01/21.html#a210
Getting More Out Of Your iTunes Library. And Your iPod
2005-07-17 14:32:49 [View]
- Trackback from #a210
Getting More Out Of Your iTunes Library. And Your iPod
2005-07-17 13:53:13 [View]
- Trackback from http://www.thunt.net/archives/000099.php
coupla cool links about managing itunes mp3 info
2004-02-03 16:06:04 [View]
-
CDDB or iTunes?
2003-10-25 10:47:16 rafedawg [View]
-
multiple artists or composers
2003-02-24 09:15:12 anonymous2 [View]
-
Filing under composer rather than artist
2003-01-23 06:23:20 anonymous2 [View]
-
Filing under composer rather than artist
2003-01-23 09:16:38 brian d foy |
[View]
-
No Dropshadows!
2003-01-22 11:56:17 anonymous2 [View]
-
No Dropshadows!
2003-01-22 12:54:35 brian d foy |
[View]
-
getting cd track names?
2003-01-20 14:50:55 anonymous2 [View]
-
getting cd track names?
2003-01-20 17:25:26 dougadams [View]
-
getting cd track names?
2003-01-20 15:01:01 brian d foy |
[View]
-
ID3.org site has changed
2003-01-20 04:03:36 dougadams [View]
-
ID3.org site
2003-01-20 04:00:46 anonymous2 [View]
-
Musical casts
2003-01-18 05:16:00 anonymous2 [View]
-
Musical casts
2003-01-18 09:01:27 brian d foy |
[View]



