iTunes for Windows script to unset Skip when shuffling

no_skip_when_shuffling.js is a script for iTunes for Windows that unsets the skip when shuffling setting on all songs in a playlist. It was inspired by an AppleScript which does the same thing for iTunes on Mac OS X.

Skip when shuffling prevents songs and podcasts from playing nice with the iPod Shuffle. It won’t play them when in shuffle mode, and more importantly, Autofill won’t see them at all. Worse, iTunes sets skip when shuffling by default on new podcasts when they’re downloaded. This script provides a workaround.

I have a Smart Playlist for the podcasts I haven’t listened to yet. Every morning, I update my podcasts, then run this script. When I plug in my iPod, Autofill syncs it so that it has only the podcasts I haven’t listened to yet.

You can download the script, or copy and paste it from here:

var playlist_name = "Podcasts";

var iTunes = WScript.CreateObject("iTunes.Application");
var sources = iTunes.Sources;
var playlists = sources.ItemByName("Library").Playlists;
var playlist = playlists.ItemByName(playlist_name);
var tracks = playlist.Tracks;

for (i = 1; i <= tracks.Count; i++) {
    tracks.Item(i).ExcludeFromShuffle = false;
}

Set playlist_name to the name of the playlist you want it to change. Then, make sure the file’s extension in Windows is .js, and double-click on it. It should be run by Windows Script Host (wscript.exe). If it’s not, change the File Type for .js files in Explorer’s Folder Options.

This script uses the iTunes COM SDK for Windows. That page has since disappeared, so I used a Microsoft TechNet article on scripting iTunes – Microsoft, weird, I know, but the article was invaluable. You can also still find iTunesCOMInterface.h on Google Code Search, among others. Finally, RipperDoc’s tutorial was helpful, as were Otto’s and Doug’s collections of scripts.

6 thoughts on “iTunes for Windows script to unset Skip when shuffling

  1. Outstanding!! 

    This is the best solution I have seen on the web for handling the iPod Shuffle problem with loading podcasts using AutoFill.  I knew the default “skip when shuffling” was an issue but needed a way to easily change the settings for all of the files. 

    It is simple, no extra programs to load, and easy to adapt for multiple playlists.

    Great job, Thank You.

  2. I just upgraded to a 5th gen ipod. After synced I tried playing a podcast playlist,… and of course things did not work as they used to.  I thought something was broken (or i was doing something wrong).

    Anyways,… thanks for the script.  Great job.

  3. Could someone walk me through the steps of using this script.  I’ve never worked with scripts and can’t get this to work.

    What I have done (Windows XP Pro):
    Created a new text document on my desktop
    Edited the document in notepad to include the copy and paste of the above script
    Changed the playlist_name to my playlist title (in this case “New_Podcast_Episodes”)
    Saved the document
    Changed the extension to .js

    When I try to run the script, I get the following error:
    Script: (the desktop location of the script)
    Line: 6
    Char: 1
    Error: ‘New_Podcast_Episodes’ is undefined
    Code: 800A1391
    Source: Microsoft JScript runtime error

    Any idea what I need to do to fix this?

    Thanks!

  4. Scott – Try adjusting the playlist name to something without spaces or underscores.  In your example, use NewPodcastEpisodes in both iTunes and in your script.

  5. I get the same error as Brian, and my playlist is named simply “Podcasts”.

Leave a Reply

Your email address will not be published. Required fields are marked *