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

A script to aid in iTunes reimported CD naming Apps
One lovely feature of iTunes when re-importing songs (i.e. they used to be MP3, and you want them as AAC) is that it will automatically copy the information from the old song only if the following data is exactly the same: track number, disc number, album name, artist name, and title. Otherwise, it thinks that it is a different song.

This can be highly annoying if you've customized every song title to a specific format (especially if it's a long title i.e. "Beethoven: Cello Sonata No.1 Mvt.2-Rondo"). Also, there is no easy way to paste in multiple song titles to a CD. So, I created a short AppleScript to copy the names from an imported album to the CD.

Make a new AppleScript document, enter the following script, and save it in the "~/Library/iTunes/Scripts" folder if you want to execute it from the iTunes script menu. Or, you can just save it anywhere and execute it manually through Script Editor.
tell application "iTunes"
  --figure out the old and the new songs 
  set theCD to the audio CD playlist 1 of source 3
  set theList to user playlist ("Copy" as string)
  
  set theNumber to the number of audio CD tracks in theCD
  
  --copy characteristics from the old songs to the cd 
  set the artist of theCD to (the artist of track 1 of theList) 
    as string
  set the composer of theCD to (the composer of track 1 of theList) 
    as string
  set the name of theCD to (the album of track 1 of theList) as string
  set the disc count of theCD to (the disc count of track 1 of theList) 
    as integer
  set the disc number of theCD to (the disc number of track 1 of theList) 
    as integer
  set compilation of theCD to (compilation of track 1 of theList) 
    as boolean
  
  --copy the names from each song 
  repeat with i from 1 to theNumber
    set the name of (audio CD track i of theCD) to 
      (the name of track i of theList) as string
  end repeat
  set the view of browser window 1 to theCD
end tell
First, create a playlist called "copy" and drag the songs from your album in the library into the playlist (it's best to choose "Sort by Album" to do this quickly). Next, choose your script from the script menu or press "play" in Script Editor. Your songs on the CD should have the same names as your old ones. Now, just press Import and choose "Replace Existing," and you've just saved yourself from manually renaming all of the songs!
    •    
  • Currently 2.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[9,858 views]  

A script to aid in iTunes reimported CD naming | 5 comments | Create New Account
Click here to return to the 'A script to aid in iTunes reimported CD naming' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Source panel
Authored by: DougAdams on May 16, '03 11:25:56AM
Use this routine to determine the true object path of the CD in the Source pane. Somethime source 3 is iPod or something else:
tell application "iTunes"
        repeat with i from 1 to the count of sources
                if kind of source i is audio CD then
                        set myPlaylist to audio CD playlist 1 of source i
                        exit repeat -- optional
                end if
        end repeat
end tell
You can see more examples of scripting playlists on this page.

Doug
Doug's AppleScripts for iTunes

---



[ Reply to This | # ]

A script to aid in iTunes reimported CD naming
Authored by: Power Factor on May 16, '03 08:57:14PM

If you had changed the CD info before you imported the first time, iTunes would have remembered the CD and recognized it as a duplicate rip.

Tip: Back up your local CDDB file. Saves some time if you have to re rip.



[ Reply to This | # ]
A script to aid in iTunes reimported CD naming
Authored by: momerath on May 17, '03 04:40:25PM

How do you back up your local CDDB file? After I imported some of my cd's a year or so ago (in iTunes 3), the CD info didn't show up. Also, people often change their info after they import the songs.



[ Reply to This | # ]
A script to aid in iTunes reimported CD naming
Authored by: momerath on May 17, '03 07:07:35PM

One John Paul Davis (http://www.johnpauldavis.org/) published an Applescript version of this hint without my authorization and without any credit to me. I sent him an email asking him to give me credit; this is just to verify that I am the author of that email. (my name is Seth Johnson).



[ Reply to This | # ]
A script to aid in iTunes reimported CD naming
Authored by: klawton on Jun 15, '03 12:48:27PM
This hint really helped. I just got an iPod so I've begun reencoding everything at AC 128 so I can fit more on it. This is my first time needing to script iTunes (or pretty much any app).

I have a couple suggestions, one of which is more of a question:

I wanted the script to clean up after itself, by emptying the "copy" playlist after use, so I changed the loop to:

repeat with i from 1 to theNumber
	set the name of (audio CD track i of theCD) to 
		(the name of track 1 of theList) as string
	delete track 1 of theList
end repeat
Since I drop each track from the playlist after it's updated, I had to change the "track i" to "track 1" in the third line. Anyway, this works, although a "delete all tracks from theList" at the end would be more intuitive.

My second suggestion/observation/question is that it seems essential that you set the sort order for the "copy" playlist to track #. I didn't have this set and it assigned all the wrong names to the tracks on the CD. Am I right about this? Would it be better to put "sort theList by track#" in the script? I can't see how to do that (I'm new to this, remember).

Thanks for the tip!

[ Reply to This | # ]