Sign in to follow this  
Followers 0
sugi

Synchronize iTunes with any MP3 Player

3 posts in this topic

I got an MP3 player a few days ago and could not find a nice way to automatically copy my music on it. Since I read about the COM interface of iTunes some time ago I decided to see how far I could get.

Currently the script only creates a directory "MP3Sync" on drive G: and copies all tracks found in the "MP3 Player" playlist in iTunes in that folder prefixed with the track numbers and does not care about synthing. It does no error checking, so it's more a proof of concept. Currently the only use of this script is to demonstrate the use of the iTunes COM interface as you could just select all tracks in the playlist and use your mouse to drag them over the drive of your mp3 player...

I intend to add some more tricks like automatic conversion to MP3 if needed, the part for looking up the encoder is already in the script. But it depends on how much time I have... feel free to use this as a staring point for your own scripts.

#NoTrayIcon
$iTunes = ObjCreate('iTunes.Application')

$mainLibrary = $iTunes.LibrarySource
$playlists = $mainLibrary.Playlists

$playlist = $playlists.ItemByName('MP3 Player')

$tracks = $playlist.Tracks()
$numtracks = $tracks.Count

$encoders = $iTunes.Encoders
For $i = 1 to $encoders.Count
    $mp3enc = $encoders.Item($i)
    If $mp3enc.Format = 'MP3' Then ExitLoop
Next
If $mp3enc.Format <> 'MP3' Then MsgBox(16, '', 'Could not get encoder')
$iTunes.CurrentEncoder=$mp3enc

for $i = 1 to $numtracks
    $track = $tracks.ItemByPlayOrder($i)
    if not $track.Enabled Then ContinueLoop
    $trackno = StringFormat('%0' & StringLen(String($numtracks)) & 'u ', $i)
    $file = $track.Location
    $fname = StringMid($file, StringInStr($file, '\', 0, -1)+1)
    DirCreate('G:\mp3sync')
    FileCopy($file, 'G:\mp3sync\' & $trackno & $fname, 1)
Next

Share this post


Link to post
Share on other sites



This actually does not work on most MP3 players out there. Mine is a sony and runs on a MySQL/OMG File format Database. This would just ruin it. My dad has 3 others that use different file formats and database patterns. Not to mention the structure of the new Ipod nano doesn't quite accept anything but the given program. I do have to say good job, but be careful before you jump to the thought of saying it works on all]/b] mp3 players.

Good job B)

AutoIt Smith

Share this post


Link to post
Share on other sites

I said that because I only know MP3 players that show up like any USB stick and simply have a FAT(32) file system on them.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0