iTunes & iPod Hints & Tips

Scripts for iTunes For Windows

Here is a selection of Visual Basic scripts that I have written to be used with iTunes for Windows.

The general method of use is to download the script to a folder of your choice, e.g. your Desktop, Downloads folder or create a folder at ...\iTunes\Scripts. Select a playlist or highlight some tracks in iTunes and then double-click on the script to execute it. If no specific tracks are selected the script will try to work with all tracks in the current playlist. Some scripts offer a choice of track by track confirmation of changes or fully automatic processing of the selection.

You are strongly advised to backup your entire library, or at the very least the iTunes Library.itl file, before use. Test the behaviour of the script on a small group of files first to make sure it does what you want before applying it to large numbers of files.

Download Link Description
AddDisc-TrackNumbers Adds leading track (& where appropriate disc) numbers to the filenames of selected tracks, unless already present. (See note #1 below)
AddToTrackNumber Adds a value onto the track numbers of the selected tracks. Use, for example, to add the track count from disc one onto each of the track numbers of disc two so that the tracks are sequentially numbered across both discs. Negative values can be used to undo an earlier change. A new feature allows a second value to be entered in the input to set the total track count. This script is particularly useful if you need to exceed a value of 999 in either the track number or track count fields as such values cannot be entered in the iTunes Get Info. dialog box.

N.b. At some point I hope to write an updated version to automatically sequence or unsequence multiple discs.
AddTrackNumbers Adds leading track numbers (only) to the filenames of selected tracks, unless already present. (See note #1 below)
AudiobookSortName Sets an alphabetically ordered Sort Name for each selected track or all tracks of the current playlist. Use to work around the way that Apple devices order audiobook tracks by track name instead of disc & track number. See Audiobooks on iPods for details.
ChangeCategory Sets the category value for selected podcast tracks.
CheckFileCase Compares iTunes records of file locations and, if necessary, corrects capitalization in file & folder names to ensure a case-sensitive correspondence. Assumes capitalization of artist & album names is consistent.
CleanDeadArt Cleans any orphaned artwork and/or empty folders left behind after iTunes or other media managers have reorganised your files.
ClearBookmarks Clears the Bookmark Position of selected tracks or all tracks in the current playlist.
ClearSkipCount Clears the Skip Count & Skipped Date of selected tracks or all tracks in the current playlist.
ClearSortName Clears the Sort Name of selected tracks or all tracks in the current playlist. Can be used to reverse the actions of AudiobookSortName. See Audiobooks on iPods for details.
ConsolidateByMoving Moves files to their new locations within the iTunes Media folder without creating copies. The script is set up to use standard iTunes naming rules, but can also be set to use full length file & folder names or, if desired, could be customised to rename files exactly as you wish, e.g. move certain genres to their own folders.
CopyAlbumToAlbumArtist Copies values from the Album field to the AlbumArtist field of selected tracks or all tracks in the current playlist.
CreateFolderArt Creates or updates Folder.jpg artwork images. If updating images then if at least one track has art it will be embedded in any tracks from the same album that are missing artwork or only have store downloaded art.
DeDuper This script can remove all but one of any duplicated files. Play and skip counts from the duplicate entries are merged and the remaining entry is updated with the most recent played and skipped dates. The best rating is also preserved.  Before running select the Music source in your library, then press down SHIFT and use File > Display Exact Duplicates to restrict the files that need to be processed to potential candidates. Select the resulting list of files before running the script. The script runs in three phases, the first identifies multiple references to the same physical files while the second identifies distinct files with the same metadata and file size. The final pass removes the duplicates from the library with the physically duplicated files being placed in the Recycle Bin.

For more details see this thread at Apple Support Communities.
FadeTunes Fades out iTunes over a predefined interval then stops. Use to have iTunes slowly fade out as you drift off to sleep. You can edit the pre fade duration, fade time, and min. volume to attain on shutdown to your own preference. These are currently set to 1 min, 15mins and 0 respectively.
FindTracks A script that attempts to locate missing tracks that have been misplaced within your library, either as a result of a third party program reorganising the media or as a result of attempting to move the library/media to a new location. Enter the location of the media folder the files should be in and the script will try to systematically fix every broken link.
ForceForeground Display, and optionally change, the value of the iTunes ForceToForegroundOnDialog state which governs whether iTunes will attempt to bring its dialog boxes to the foreground.
GetInfo Test/demo script that provides a way to view a selection of track properties, in particular those such as Bookmark Position that cannot be displayed in iTunes but can be accessed via the iTunes COM SDK.
ImportM3U Drag & drop an M3U playlist onto this script to import it into your iTunes library. Created as a workaround to the M3U import bug with iTunes 10.4. Also useful if you wish to import a playlist containing WMA files.
iTunesInfo Test/demo script that provides a way to view iTunes properties such as the state of the Media Key Processing option that cannot be displayed in iTunes but can be accessed via the iTunes COM SDK.
iTunesXMLPath A simple script that reveals the path to the active iTunes XML file.
KeywordsToComments Prompts for a keyword (or phrase) to add to the Comments field, without removing what is already there or adding the same keyword twice. Prefix a value with a dash to remove. Adds new comments on separate lines.
The following field tags will be replaced with their values: <Comment>, <Genre>, <Grouping>, <Location>, <Lyrics>, <Year>. You can also use \n to insert a new line.
KeywordsToGrouping As KeywordsToComments, but changes are made to the Grouping field. An advantage of using Grouping as opposed to Comments for storing your keywords is that you can display all your different groupings in the Column Browser and easily display any selection of them. This script separates the keywords with a slash and sorts them but these options can be changed if required.
KeywordsToLyrics As KeywordsToComments, but changes are made to the Lyrics field. Insert data into this field if you want to be able to view it from the Lyrics tab during playback on an Apple device. By default this script inserts new keywords before any existing text, separated by a new line, and does not sort to preserve any lyrics that may already be there.
KeywordsToName As KeywordsToComments, but changes are made to the Name field. This script appends new keywords after the existing text, separated by a space and does not sort. Use, for example, to append comments such as [Live] to every track in an album or use -(LIVE) [Live] to replace existing markup with your preferred text.
KillEmptyPlaylists Removes empty playlists inadvertently created in the top level of the library. Antidote to a bug in iTunes 10.4 that could cause empty m3u files to be created if you attempted to add new tracks to your library by scanning the entire media folder. I recommend using iTunes Folder Watch for the task of adding new tracks and removing orphaned entries.
KillTopLevelPlaylists Similar to KillEmptyPlaylists but kills all non-smart playlists not in a playlist folder apart from Purchased and Voice Memos. Use to delete redundant artist/album playlists that may have been created by third party software and then imported into your iTunes library. Make sure to put any non-smart playlists that you want to keep into a playlist folder before running the script and have a backup of your iTunes Library.itl file too, just in case.
LastPlayedNever Unlike the built-in Reset plays command, this script also resets the Last Played & Last Skipped dates to Never, and resets any stored Bookmark Position.
LocaliseM3U Drag & drop an M3U playlist onto this script to change the absolute path references to pointers to files in the same folder as the M3U file. Use to update a playlist exported from iTunes so that a folder with the playlist and its files dragged out from iTunes can be used with third party software or devices.
MaximiTunes Maximizes the iTunes window, launching iTunes if not already open. Does the reverse of MinimiTunes but is unlikely to be of any use whatsoever...
MediaKeyProcessing Display, and optionally change, the value of the iTunes AppCommandMessageProcessingEnabled state, which governs whether iTunes will attempt to respond to keyboard media key control requests such as Play, Pause, Next Track etc.
MinimiTunes Minimizes the iTunes window, launching iTunes if not already open. Use as a start-up script to open iTunes and minimize to the task bar so iTunes is available for Wi-Fi syncing.
RelativeM3U Drag & drop an M3U playlist onto this script to change the absolute path references to relative pointers to files in artist & album folders below the folder containing the M3U file.
ReplaceTextInName Replaces instances of one set of characters with another. Call the script and enter your search and replacement text.
SortDateAdded Removes selected tracks from iTunes and then reimports them in reverse track number order so that the tracks are in the correct order when viewing the library in Date Added (descending) order. All volatile metadata (except Date & Added & Date Modified) such as PlayCounts, Rating, Equaliser Preset etc. that isn't stored in tags is preserved by the script which updates the reimported files with the data that would normally be lost if you tried to do this task by hand.

The is an optional switch to reverse the order if you prefer to have things arranged in Date Added (ascending) order.
StripTrackNumbers Strips any leading track & disc numbers from the filenames of selected tracks. (See note #1 below)
SwapAlbumArtistAlbum Swaps values between the AlbumArtist & Album fields.
SwapArtistAlbum Swaps values between the Artist & Album fields.
SwapArtistAlbumArtist Swaps values between the Artist & AlbumArtist fields.
TagFromFilename Attempts to parse the full file path for selected tracks in order to update the values of Album Artist, Album, Artist, Disc No., Track No, Track Title and Compilation status. Also adds folder art if possible. Use to construct track info. for .wav files or files that are missing tags but are set out in conventional artist & album folders. (See note #1 below)
TrimName Trims a user-selected number of characters from the left or right of the name field for selected tracks, useful for stripping unwanted track numbers from the name field.
Unconsolidated Searches selected tracks or the entire library for unconsolidated tracks and if found creates a playlist containing them. Will also report if there are any dead tracks.
UpdateTagInfo Forces iTunes to compare each file's tag with iTunes own record and updates iTunes if necessary. Use to update iTunes after modifying tags with 3rd party tools.
N.b. Previously this has been easy to achieve in iTunes by selecting tracks, using Get Info., and then clicking OK. As of iTunes build 9.2.0.25 this method appears not to update properly hence this script.
   
Note #1 The scripts AddDisc-TrackNumbers, AddTrackNumbers, StripTrackNumbers & TagFromFilename, which manipulate filenames, may only be useful if you disable the advanced iTunes preference to Keep iTunes Media folder organised or are working with files stored outside of the designated iTunes Media folder. If iTunes is organising the files and they are located inside the media folder then iTunes will simply undo any changes made by these scripts.

Disclaimer
Although I have tested these scripts thoroughly I make no representations as to their suitability for your purposes. Please ensure you have a backup of your library and media folders before running any script on your system.