3rd Revision: iTunes Playlist to Clip (Mac/OS X) script

For those of you who may have downloaded my script for exporting an iTunes playlist as an M3U file for the Sansa Clip, I revised the script to address an issue that has been brought to my attention recently by forum members. The revised script is now available at the download site provided in my original post, i.e., here: http://sharefiles.quietlakephoto.com/scripts/itunes2clip_download.html

The issue in question occurred when the iTunes playlist (to export) contained non-MP3 format tracks. Originally my script was designed assuming all playlist tracks were in MP3 format (since the Clip plays only MP3). With this revision I have changed the readme file Description section to state:

This applescript works with iTunes to allow exporting iTunes playlists in the M3U format as required by the Sandisk Sansa Clip mp3 player when in the USB mode: MSC. It will export any playlist created in iTunes, however, if the playlist contains non-MP3 format tracks, e.g., MP4, M4A, WAV, AIFF, etc., you will be alerted that those tracks must be converted and that they will not be included on the exported playlist.

And the code had been revised as follows:

* Added code to detect for non-MP3 tracks in playlist. If detected, user is alerted and informed the track must be converted. The track is not processed and not included on the export Clip playlist. I did not build-in conversion to MP3 for several reasons: 1) the iTunes script function, convert, runs asynchonous and I did not want to work on that problem given that, 2) I decided it would be best to let the user decide if and how they want to do the conversion, e.g., do they want certain enocoder quality settings (these are not scriptable), and do they want to keep both the original and the converted version.

Message Edited by kwanzan on 08-27-2008 09:22 AM


I did everything you suggested, it workrd but the next days my FM radio disapperead and only one tune plays…

What happened?

Hello there!

I just bought a 2 gig Clip and am using OS X 10.5.4 with iTunes 7.7. I placed your applescript in the iTunes folder, but the Applescript icon doesn’t appear in the menubar when restarting iTunes, and running the script from Script editor, I always get this error message: “File some object wasn’t open”. Please help. 

Is there also a way to get it to scrobble plays to submit to last.fm?  Or is that asking too much? :slight_smile:

Message Edited by maluze on 08-31-2008 07:59 PM

Maluze -

I hope this is not an iTunes version problem, as I have only tested my script with v7.6. However, based on your message, I am wondering if you have copied the script to the correct location. The correct location is:

/User/USERNAME/Library/iTunes/Scripts  (where USERNAME would be unique to your computer)

Under iTiunes 7.6, if you copy any script (extension .scpt) to this location, it will immediately be listed under the iTunes script icon, meaning you would not have to restart iTunes to have access to the script.

Use the Finder, Get Info, on the script where it currently resides on your computer. If the Where value does not match what I’ve given above, then that is likely the problem.

Please let me know what you find out.

Regarding, your last.fm and scrobble question, personally, not familar, but I might look into it once we get the script working for you. 

Hehe…I put it in the user/username/music/iTunes folder instead of the user/username/library/iTunes folder…how dumb of me. It works now.

I really wish songbird or iTunes could be made to work with the Clip in OS X…

We tried using your script on the Fuze, but have Itunes v. 8.  There is no script folder–just a plug ins folder, so we tried putting the file in there, but it did not show up in itunes.  The script worked to put a playlist on the Fuze, however, it was empty.  I tried opening the playlist file and manually putting in each mp3 file and then saving the file, however the playlist on the Fuze was still empty.  Any suggestions?

OK, here’s the deal.

My script has been written specifically for the Sansa Clip; I don’t own a Fuze. However, if the Fuze has the same file structure as the Clip, then you might be able to use my script with it.

To determine if it will work, you will need to take a look at the Fuze drive as it appears on your Mac Desktop. When you double-click the icon, look for a folder named, MUSIC (all caps), and for a file named, version.sdk.  If there is a folder named, MUSIC , and a file named, version.sdk and if songs are stored on the Fuze in the MUSIC folder in the same way as they are on the Clip, then you will problably be able to use my script.

Regarding your comment, “There is no script folder–just a plug ins folder”, here is the first step in my installations instructions (in the readme file provided with the download):   Create a subfolder named, Scripts, in your Users:UserName:Library:iTunes  folder. That should help you with the install of my script.

Good luck. 

Hi kwanzan,

Thanks very much indeed for your script - very helpful!  I’ve been using it on my fuze, and whilst it works fine in putting playlists onto the machine I’ve got a minor problem.  

Each time I put a playlist onto my fuze, it seems to get ghosted with an empty playlist beginning with ._ 

This isn’t a major problem, but I can’t find these ghostly playlists on the file tree to delete them (unless I delete the original list), so I seem to be amassing a list of ._ playlists…

Any ideas how to sort that out?

Apologies if this is incoherent - I’ve been playing around with this for ages, and my brain is going to mush.

riknorris -

I will try to help you with this issue, but my suggestions at this moment may be of limited value. I am out of town and do not have OSX conveniently available, so will be just giving you some “best” guesses. Also, I do not possess a Fuze and have never actually used one. I wrote my script for the Clip.

OK, enough conditionals…

I believe the ._ “ghosts” that are encumbering your playlist display, are a result of OSX creating a “resource” file associated with any file that it “creates” on the Fuze volume.

So, here’s the one idea I have for removal (which I cannot verify at this moment because I do not have access to OSX). You will need to use the Terminal under OSX.

In a Terminal window, you will need to navigate to the MUSIC directory of your Fuze. The command should be something like:       

                           cd   /Volumes/NAME OF YOUR FUZE/MUSIC

Once in the MUSIC directory, issue this command:

                            ls -lsa

This should give you a list of the files and folders in your MUSIC directory, including those that are “hidden”. In OSX, any file that has a name that begins with a period will be invisible under Finder,  hence the reason to use the Terminal.

If you have succeed in listing your file/folders, then you should see those unwanted ._playlistname files in the list.

Now, here is the guessing part. I know how to tell you how to remove those files. What I’m not 100% certain about, is whether they are important to the Fuze. So I suggest you try the removal of one such “ghost” file and then dismount/eject your Fuze from your Mac and take a look. If all is working normal, and your non-“ghost” playlist still works, then we have succeeded.

To remove the  unwanted file, use this command:

                          rm  ._playlistname


These “ghost” files may also be present on the Clip, but they are not visible in the Clip display. Again, since I do not currently have access to OSX, I cannot examine (ls -lsa) the Clip volume under Terminal.

That’s the best I can do at the moment. Let me know how it goes.

Thanks, kwanzan, for the great script. I was considering returning my Fuze because it’s not too Mac friendly, but your script made me change my mind.

I experienced the same problem as riknorris, with ._ ghost files for each actual playlist and mp3 file. I deleted these in Terminal using rm ._* in the appropriate directories. Everything works well now. One question though, is there any way to select a playlist and have it play automatically?

Thanks Kazwan!

The terminal solution hadn’t actually ocurred to me.  In the meantime I found another solution in another forum, which was to download mucommander , and use that to find and delete the hidden files.  

I’d never heard of it before (I’m pretty turd with computers), but it allows you to actually browse through the files which is handy. 

Incidentally, I was getting the same ._* ghost files for any track that I had ripped in itunes (which was quite a few)… 

Thanks again.

Thanks Kazwan - you just saved me a whole lot of trouble. Great little script!

Mandapandapop -

Your welcome. Always nice to get feedback, so thanks for taking the time to drop a note. 

Just signed up to say thank you Kazwan!  Your script has been a great help to me as I own both a Fuze and Clip - it works perfectly on both.  Good work!

jamiemutley -

Ditto my response to Mandapandapop, previous. Thanks for the feedback.


I was very happy when I found your script, but the playlist is shown empty on my Sansa Clip.

Could that be due to the fact that I have iTunes 9?

The script is nicely shown in iTunes and seems to work perfectly. The songs are copied and arranged in separate folders according to the artists.

But when I access the playlist on the Sansa Clip, it appears empty.

Any idea why?

I have read other comments in this thread and I have looked for hidden files, but didn’t find any.

braut2 -

Hmmm, I’m starting to get a bad feeling. Another person in a private email said the script “worked like a charm” but he received an error message during its execution. He too is running iTunes 9.

So, I (relucantly, I personally don’t want every new version of iTunes) installed iTunes 9 on a backup system, tested it and it worked as always.

However, you may have the difference the other individual had; he was running OSX 10.5.8, and I am running 10.4.11 (Tiger).

As I told the other individual, if you want to help me out here you can do two things. First, email the XML file created for the playlist that did not work. You can do this in iTunes with File:Library:Export Playlist and export as XML. You can also email the .m3u file created on the Clip.

I can analyze those files and try to discover a clue to the problem.

It’s up to you if you want to help me resolve the issue. Send the email to the address you find in the download Readme file.

I’m guessing Apple would like to make it harder and harder for any other device than the iPod to work with iTunes. Those devious, little, bas…

Good news, for those interested.

Apparently a bit of a false alarm from braut2; just an oversight in using the script.

Reports to me that it seems to be working fine, though a potential (very minor) bug was brought to my attention in the process of investigating the problem.

Which I plan to fix (and perhaps less than 1% of users will ever know the difference).

Thanks very much for this script. I downloaded and ran it with Mac OS 10.5.8 and iTunes 9 (following the “read me” instructions exactly) and it worked beautifully. Going out now to walk the 100 lb lab with my playlist. Thank you!

Message Edited by jcdb on 10-15-2009 03:14 PM

Can someone email me the script? The web site seems to be down. alansky at gmail.com  thank you!