Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Why didn't they stay in their playlists?

I looked at the size of my library - huge! It's huge becuase I ripped all my CD's to iTunes as aiff to maintain quality a while back, but now I figured it was time to convert to Apple Lossless. I went to the iTunes music folder, filtered by bitrate to select out all the 1411 Kb aiff files, selected all of them, and right clicked to convert to Apple Lossless. The process went smoothly enough, but when I checked, the conversion had stripped all the playlist assignments for every tune. I had a bunch of empty playlists, and a huge list in "recent imports", all piled in to this single huge file.


I shouldn't have to go back and re-assign every tune to it's previous playlists just because I wanted to convert format. There must be a workaround that leaves them with the playlist designations before they were converted. Can anybody offer any help? Presently, I am just letting time machine rebuild the old files.

iMac, Mac OS X (10.6.7), 27 inch i7

Posted on Mar 31, 2012 4:13 PM

Reply
17 replies

Mar 31, 2012 4:51 PM in response to aimpromo

When you convert a song to a new format you are adding a new song to the library. It will, to start with, only be a member of any SmartPlaylist to which the its metatdata qualifies it for. I'm guessing it wouldn't be too hard to write an AppleScript to convert the file and at the end of the conversion add the track to all non-smart playlists that the original was a member of.


tt2

Mar 31, 2012 9:40 PM in response to turingtest2

It does seem as relatively "simple" as copying the playlist data, doing the conversion and pasting the playlist data back on to the new file, but I am afraid I haven't had any sucess at a script that does that. I am pretty weak in the script department. I did just send it in to Apple as a product suggestion for iTunes, but I am not very hopeful with that request. I was quite surprised that it was not already a feature of iTunes.

Apr 1, 2012 3:21 AM in response to aimpromo

I've had a quick hunt around Doug's AppleScripts for iTunes but I can't find anything suitable. I don't have a Mac but I've written quite a few scripts for the PC. In essence what you want is something a bit like this:


For each selected track T

Convert T to new format as U

Set P=T.Path

Set T.Path=U.Path

Set U.Path=P

Delete U from library, sending file to trash

Next track


That way the newly converted tracks would inherit all the properties of the originals; date added, play count, last played, rating, etc. and specifically playlist membership (with the exception of those based on media format).


I've no idea how you would go about converting the pseudo code above into AppleScript, but it ought to be fairly easy.


In fact I might even write the Windows version to add to my collection at some point.


tt2

Apr 11, 2012 2:53 PM in response to aimpromo

It is not so easy to find which tracks are in which playlists using AppleScript. You'd probably like to think it's as easy as writing "give me a list of the playlists that contain this track" (in AppleScript syntax, of course). But that's not how the iTunes database is set up. To discover which playlists contain each track (that's the way to approach it), you essentially have to go through a list of each track and ask each playlist if it contains that track. That's (number of tracks) X (number of playlists) tasks. It takes a long time.


Some would say that iTunes should provide this option. How? Let's say I want to convert a track that is in three different playlists. What is iTunes to do? As k which of those playlists you want to copy the converted track to? For each track?


I have a script called Quick Convert that will copy a batch of converted tracks to a particular playlist. But you have to know ahead of time which playlist you want them copied to. It does not default to the current playlist, but perhaps this is a feature I can include. Or, you can just select a batch of newly-converted tracks, right-click, and choose "Add to Playlist".


I don't know why the OP lost his original source files. iTunes' conversion routine merely converts the track and adds it to the library--and it should copy most meta-data. It has no affect on the source tracks or their files. So there's something fishy going on there.

Apr 11, 2012 3:24 PM in response to Doug Adams

Hi Doug, I'm not aware the OP lost any files. It is just that the newly converted files don't automatically become members of the same playlists as the originals. Can you change the location property of a selected track in iTunes for Mac via AppleScript as you can when working with iTunes for Wndows? If so you can replicate my approach. By making the original track entry point at the newly converted file this track remains in all the playlists, and picks up the ratings, play counts, date added values etc. The new entry is then connected to the old file which is sent to the trash and the new entry, now no longer required, is removed from the library. There is no need for an exponential search. Assumes of course that you can do something equivalent to the psuedocode above and capture a pointer to each newly convered file.


tt2

Apr 11, 2012 4:21 PM in response to turingtest2

The OP said: "but when I checked, the conversion had stripped all the playlist assignments for every tune. I had a bunch of empty playlists". My assumption was that if he had lost the tracks--however that happened--that he lost the files since conversion works on files, not tracks. In any case, the original source tracks should not have disappeared from any of the playlists they were assigned to. Fishy.


I'll leave the mods to others. The AppleScript property to change for a track's file path in iTunes is location. Copy this value from the original track to the newly converted track, delete the original track from the library (which will remove it entirely from iTunes) and optionally delete its file, either via the Finder which will move the file to the Trash, or with the unix command "rm" which will delete the file instantly.

Apr 12, 2012 7:55 AM in response to Doug Adams

Hi Doug,


Maybe I wasn't as clear as I should have been in my OP. Way back when, I pulled tracks from my CD as aiff. Lets say that was Aerosmith. I then put various tracks from the album as Aerosmith, Steve Tyler, Rock, ballad, blues, 5 star, etc. I now want to convert those to apple lossless. When I do the conversion via iTunes by right clicking the selected tracks and choosing "convert to Apple Lossless", all the ALAC tracks are no longer in "Aerosmith" or any of the other previous playlists. They show up in the "recent imports" smart playlist, and all the old playlist data is gone.


The old aiff track is still there with the original playlist data, but the apple lossless files contain no playlist data. I am putting all my AIFF's to lossless, so that is easily thousands of tracks in multiple playlists. I would have thought that if apple provided the command to convert, that the data would be copied from the original, and pasted into the new file, with the old aiff being trashed as turingtest2 has done with his windows scripting.


Am I gathering from you that in the OSX version of iTunes, that is not possible, but it is in Windows because of the way OSX data is structured?


My apologies if the original post wasn't clear enough.


Cheers; Rick

Apr 12, 2012 11:22 AM in response to aimpromo

OK. Tracks do not contain playlist data. A track doesn't have any properties associated with playlists. A track doesn't "know" what playlists contain it. So, a track cannot "lose" its playlist data.


Playlists, however, contain entries which are essentially pointers to track entries in a library--in this case, the Music library. If you know something about databases you can consider a playlist to be a sub-table whose rows each contain one cell, and the value of that cell is an identifier of a track in the larger library table. If you open the "iTunes Music Library.xml" file in a text editor like TextEdit, you will see how iTunes oranizes its library.


That is only pertinant with regards to your assumption about what Convert does. The fact is, when you Convert with iTunes, you are creating a new file and it is added as a new track entry in the appropriate library. Convert does not replace. Perhaps Convert is an unfortunately ambiguous word.


I get dozens of requests for script mods a week, as you can probably imagine, which I can't possibly make time for. But at some point I will add the option to replace, as I explained it in my post above, to my Quick Convert applet.

Apr 12, 2012 11:50 AM in response to Doug Adams

Hi Doug...


The approach I'm using (in this thread) is to find the path of the newly converted file and modify the original track entry so that it is now connected to the new file, then throw away the "new" iTunes entry and send the "old" file to the trash.


iTunes will figure out that file format, size etc. have changed when you make the assignment, but most importantly the entry retains all of its previous non-tag-embedded data, that is playlist membership, rating, play/skip counts, date added, played, skipped, eq setting etc.


A minor refinement I've added today at the request of the OP in that thread is that the new version of the file ends up at the same path as the original, barring any change of extension to reflect file format.


tt2

Apr 12, 2012 9:56 PM in response to turingtest2

Hi turingtest2,


I tried this windows script tonight within parallels Win XP by adding a couple of new aif tracks into iTunes, then setting the import settings to ALE. When I ran the script, it did make a new converted file, but didn't transfer the playlist data and left an empty track where the aif file was - ie a title without any content.


I got this VBscript runtime error message.


Line 134

Char 3

Error File already exists

Code 800A003A

Apr 13, 2012 4:03 AM in response to aimpromo

Hmm. The orignal file is supposed to go to the recyle bin, the new track should end up in the same place as the original used to be. Line 134 in that build moves/renames the converted file. It doesn't check for a prior file of the same name since, even if we are converting between the same formats, the original should have been removed 3 lines earlier. I can add in an existence check & error handler before the move/rename to catch that but unless the folder already contained an aac/ale version then I can't see why that happened.... <thinks>


Doh! I have my library in a non-standard layout, as I suspect does Carlos Gil which would explain why he wanted the files moved from the standard iTunes "rip" location to where he has arranged his files. I ran over a dozen tests yesterday running between different formats without any trouble. My guess is the script fell over for you because with a standard layout line 134 tried to move the file onto itself... Mea culpa! 😊


Because the process was halted the steps that would have connected the original entry to the new file, and then removed the new entry never happened. When you say "empty track where the aif file was..." I'm guessing you now have a broken entry with the exclamation mark of a missing file rather than a zero length file. That entry should still be in its respective playlists. Restore the deleted file from the recycle bin and that entry should come back to life.


I've uploaded a new version of ConvertFormat which should work properly now. (Fingers crossed)


BTW for clarity it isn't that the playlist data gets copied across to the new entry, rather that the old entry gets connected to the new audio. This cuts down most of the effort that would otherwise be required to perform the desired task. Playlists are ordered lists of track objects so reusing the same object means it remains in the playlists.


tt2

Why didn't they stay in their playlists?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.