Syncing iTunes Playlists From Windows 7 To A Nexus 4

* Connect both devices to a common WiFi AP and determine their IP addresses (Windows/Nexus)
* Download a capable SSH/SFTP/SCP server app that also allows you to setup a capable login user (Nexus)
* Download and run “dokan-sshfs” and then connect to and mount the phone as a “U:\” drive (Windows)
* Run the “syncplay.js” wscript below to sync a smart playlist called “recent” to the phone (Windows)

var iTunesApp = WScript.CreateObject("iTunes.Application");
var mainLibrary = iTunesApp.LibrarySource;
var playlists = mainLibrary.Playlists;
var numPlaylists = playlists.Count;
var fileSys = WScript.CreateObject("Scripting.FileSystemObject");

while (numPlaylists != 0)
{
	var currPlaylist = playlists.Item(numPlaylists);
	
	if (currPlaylist.Name == "recent")
	{
		var playlistTracks = currPlaylist.Tracks;
		var numTracks = playlistTracks.Count;
		
		WScript.Echo("[" + currPlaylist.Name + ":" + numTracks + "]");
		
		while (numTracks != 0)
		{
			var sourceTrack = playlistTracks.Item(numTracks);
			var targetTrack = ("U:\\sdcard\\Music\\" + fileSys.GetBaseName(sourceTrack.Location) + "." + fileSys.GetExtensionName(sourceTrack.Location));
			var sourceSize = fileSys.GetFile(sourceTrack.Location).Size;
			var targetSize = 0;
			
			if (fileSys.FileExists(targetTrack))
			{
				targetSize = fileSys.GetFile(targetTrack).Size;
			}
			
			//WScript.Echo("[" + sourceTrack.Name + ":" + sourceTrack.Location + ":" + targetTrack + "]");
			
			if (sourceSize != targetSize)
			{
				fileSys.CopyFile(sourceTrack.Location, targetTrack);
			}
			
			numTracks--;
		}
		
		//add check to remove uneeded songs
		//create a playlist xml file
		//force device refresh
		WScript.Echo("Done");
	}
	
	numPlaylists--;
}

Advertisements
Syncing iTunes Playlists From Windows 7 To A Nexus 4

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s