Currently Being ModeratedMar 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.
Currently Being ModeratedMar 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.
Currently Being ModeratedApr 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
Delete U from library, sending file to trash
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.
Currently Being ModeratedApr 11, 2012 1:24 PM (in response to turingtest2)
In case anyone is interested I've made good on that intention. For Windows users ConvertFormat works as discussed above.
tt2Various PCs, iTunes 10.5.2.11, Windows XP Pro, iPad 2,iPhone3GS,iPod Classic+Nano
Currently Being ModeratedApr 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.
Currently Being ModeratedApr 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.
Currently Being ModeratedApr 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.
Currently Being ModeratedApr 12, 2012 7:55 AM (in response to Doug Adams)
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.
Currently Being ModeratedApr 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.
Currently Being ModeratedApr 12, 2012 11:50 AM (in response to Doug Adams)
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.
Currently Being ModeratedApr 12, 2012 9:56 PM (in response to 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.
Error File already exists