iTunes Hints & Tips

iTunes For Windows Scripts

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

The general method of use is to download a script (double-click or right-click and use Download or Save link as...) 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 or sometimes the entire library. Some scripts offer a choice of track by track confirmation of changes or fully automatic processing of the selection. Many of the scripts can optionally display a progress bar while running.

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 your chosen script on a small group of files first to make sure it does what you want before applying it to large numbers of files.

Please note that some older scripts may crash if they attempt to process "tracks" that are available in iCloud but not on your computer. To avoid this either create a selection that excludes iCloud items or use Edit > Preferences > Store and untick Show iTunes in the Cloud purchases.

 

Download Link
Description
AddComposerToName Prefix the value of Composer to the Name field for selected tracks or all tracks in the current playlist.
AddDisc-TrackNumbers Adds leading track (& where appropriate disc) numbers to the filenames of selected tracks, unless already present. Note this modifies the filename only and track and (optionally) disc numbers must be present in the tags to start with. This script along with AddTrackNumbers & StripTrackNumbers were written to replace features dropped in iTunes 8.
(See note #1 below)
AddToPlays Adds to or subtracts from the current play count of selected tracks or all tracks in the current playlist. Use, for example, on a list of recently played items to remove a batch of unwanted increments to the play count.
AddToPurchased Adds purchased/protected tracks from current selection or playlist to Purchased playlist if not already in it.
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. See also Organizing audiobok chapters for more on this topic and an AppleScript version of this script.
AutoSort Clears Sort Album, Sort Album Artist, Sort Artist, Sort Composer, Sort Name, and Sort Show fields which begin A/An/The to restore the AutoSort feature of iTunes for selected tracks or all tracks in the current playlist. See also UnAutoSort below.
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.
CleanDeadApps Cleans any orphaned files from the Mobile Applications folder if the apps are no longer in your iTunes library or exist in newer versions.
CleanDeadArt Cleans any orphaned artwork and/or empty folders left behind after iTunes or other media managers have reorganised your files.
ClearAlbumAutoRating Clears/prevents Album AutoRating by setting album rating to 1%. Use ResetAlbumAutoRating to restore AutoRatings.
ClearBookmarks Clears the Bookmark Position of selected tracks or all tracks in the current playlist.
ClearEpisodeNo Clears the Episode Nunber fields of selected tracks or all tracks in the current playlist.
ClearLyrics Clears the Lyrics 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.
ClearSortFields Clears each of the various sort fields 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.
ClearTrackAutoRating Clears/prevents Track AutoRating by setting track rating to 1%. Use ResetTrackAutoRating to restore AutoRatings.
CombineStats Combines the play & skip counts, takes the highest rating and most recent played & skipped dates of selected tracks or playlist between iTunes and a manually managed iPod/iOS device. Will attempt to match tracks first on LibraryIDs and if that fails on tracks with the same tag information. Related to SyncStats.
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. You can also use this script to move selected content to a media folder on a different drive, e.g. to move movies or TV shows to an external drive to free up space. If a file to be copied already exists at the target location the original will be left in place and iTunes connected to the updated path. This prevents errors when the same folder can be reached via different links, mapped drives or UNC paths.
ConsolidateByMovingLong As ConsolidateByMoving but can generate file & folder names longer than iTunes 40 character limit and has different character substitutions for characters that cannot be used in file paths.
ConvertFormat Converts selected files or the current playlist to the format used in Edit > Preferences > General > Import Settings. The newly converted files will replace the originals inheriting ratings, play counts, playlist membership etc. and the original files will be sent to the recycle bin. Backup first and use with caution as these actions are not easily reversed if you make a mistake. If present any Folder.jpg images in the source folders will be added to tracks that didn't previously have art, target format permitting.
CopyAlbumToAlbumArtist Copies values from the Album field to the AlbumArtist field of selected tracks or all tracks in the current playlist.
CopyArtistToAlbumArtist Copies values from the Artist field to the AlbumArtist field of selected tracks or all tracks in the current playlist.
CopyNameToSortName Copies values from the Name field to the SortName 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.

Do not use if tracks from different albums may be stored in the same folder.
CustomRenamer Similar to ConsolidateByMovingLong but allows you to set your own pattern for file and folder names using keywords in the same manner as ExportToFolder.
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 and user playlist membership is also preserved. Before running select the Music source in your library, then press down SHIFT and use View > Show Exact Duplicate Items to restrict the files that need to be processed to potential candidates. Select the resulting list of files before running the script. The script makes five passes over the data, first identifying any repeat entries in a playlist (playlist duplicates), then next any multiple references to the same physical files (logical duplicates), the third pass identifies distinct files with the same metadata and file size (physical duplicates) or the same file visible via two distinct paths (pseudo-physical duplicates), the fourth identifies files of different size with the same metadata (alternate duplicates) and the fifth identifies missing files that are duplicates of tracks that are still present in the library (missing duplicates). As the script progresses ratings, play-counts, and playlist membership are transferred from the entry that will be discarded to the one that will be kept. A final pass automatically removes all duplicates or optionally removes selected files from the different classes of duplicates with the physically duplicated files being placed in the Recycle Bin just in case you find you want to restore them later.

See this thread at Apple Support Communities for the genesis of the script and this post for a detailed description of how to use it.

WARNING Extreme caution should be used with this script if your media is on Network Attached Storage. The current version should cope properly with pseudo-physical dupes but there is no recycle bin to restore files from if anything is deleted in error. Recovery of deleted files from NAS is non-trivial.

Please backup your entire library before using this script so that files could be replaced if necessary.

N.B. The file recycling function in this script will need tweaking for non-English versions of Windows. Currently support has been added for Dutch and German. Contact me via email or find me in a recent thread at Apple Support Communities.

When dealing with duplicates of different size DeDuper will preserve the largest as it is likely to be the best quality. There are options that can be adjusted in the initialisation section of the script if you want to remove all but the smallest file, prefer one format over another, want to select by date added or modified, or archive the duplicates rather than deleting them. The deletion routine may generate unwanted prompts if it needs to delete purchased media. Signing out of the iTunes Store is advisable if you have managed to import duplicates of your iTunes purchases to avoid unwanted prompts or the hiding past purchases.
DetailFromPath Pulls a detail from the file path, currently the first word separated by a space, comma or dash from the rest of the file name, and applies it to selected fields, currently Album Artist, Artist and Composer.

Niche script written for this thread: Keeping MP3 files in alpha order. Could be adapted as required.
DifferentArtistAlbumArtist Compares Artist and Album Artist for non-compilation tracks. Any found will be added to a playlist called FixArtist. Use to ensure all tracks from the same album have the same artist as different artists can cause albums to break up on older iPods. See One album, too many covers for details.
Duplicates For iTunes 11.0.0 only
Search selected tracks or the entire library for duplicate tracks (same song name) and if found add to a playlist called Duplicates. Unlike ExactDuplicates this is rarely a useful subsection of the library, and becomes less so with larger libraries. With my library this list currently matches almost a third of my library whereas ExactDuplicates lists the 78 exact duplicates that I've deliberately introduced for test purposes.

Replaces the feature that was missing from iTunes 11.0.0 (but very slow in comparison). Upgrade to iTunes 11.0.1 or later in preference.
DuplicateSong&Artist Search selected tracks or the entire library for tracks with the same song name & artist and if found add to a playlist called Duplicate Song & Artist. This is a preliminary proof of concept for a script designed to make sure a regular playlist has only one copy of each song (defined as same song name & artist so different covers, or different songs with the same name, can still appear). In contrast to Duplicates this script matches about one sixth of my library.
EmbedData Attempts to embed data that is in the iTunes database but missing from the tag when viewed in another media player or tag editor. The published version can force update the fields: Album, Album Artist, Artist, Comment, Composer, Disc No., Genre, Grouping, Name, Track No., & Year. Edit the Fix<FieldName> assignments to update only fields that need changing. Could be extended to work with other fields as required. If the tracks in question are not tagged at all then select them in the songs view, right-click, and use Convert ID3 Tags... > v2.3 instead.
EmbedFolderArt Embeds the largest image (by area) stored in the same folder as each processed track. Any "store downloaded" artwork is saved as iTunesArt in the same folder as the song and may be subsequently embedded if it is the largest image.

 Do not use if tracks from different albums may be stored in the same folder, use EmbediTunesArt instead.
EmbediTunesArt Creates a cache of iTunes downloaded or embedded artwork, then embeds art into any track that doesn't have embedded art. Unlike CreateFolderArt or EmbedFolderArt this script can be used when you might have tracks from different albums stored in the same folder. 
EnableLUA Reports the current state of the Limited User Access policy setting and allows you to change it. This script may be needed to allow other scripts to display a progress bar as they operate.
EpisodeNoToTrackNo Copies values from the Episode Number field to the Track Number field of selected tracks or all tracks in the current playlist.
ExactDuplicates For iTunes 11.0.0 only
Search selected tracks or the entire library for exact duplicate tracks (same song name, album, artist, track no. & disc no.) and if found add to a playlist called Exact Duplicates. This script is slightly more inclusive than iTunes own feature as it matches disc <none> with disc 1.

Replaces the feature what was missing from iTunes 11.0.0 (but very slow in comparison). The resulting playlist is ideal as a source list for the DeDuper script.
ExportAppInfo A variation of ExportCSV that exports information about selected apps.

See this thread at Apple Support Communities for more details.
ExportCSV Exports selected metadata as a CSV text file suitable for import into Excel. The current version exports multiple records for each track that has multiple artwork, however the artwork details can be omitted if not required and the script could easily be adapted to export additional information. A new addition exports a field that lists each of the playlists a track is in.

See this thread at Apple Support Communities for more details.
ExportImport Exports or imports selected metadata. Can be used to attempt to restore data such as ratings, playcounts, genres, or other corrupted metadata from a previous iTunes library file, or to export properties before files are replaced with better quality versions, and then restore that data to the replacement files. To export data from an older database first restore or connect to an older library file, select the tracks of interest, then run the script to export. N.b. You may need to temporarily rename the iTunes Media folder during the export phase so that iTunes cannot read the current tags of the files if your aim is to retrieve earlier versions of that information. The output file ExportImport [<Date>] [<Time>].txt is placed in the same folder as the script. Next restore the name of the media folder if you had changed it earlier, then restore or reconnect to the current database and drag & drop the output file onto the script to import. The current version of the script is set to export most, but not all, user editable fields and could be edited to bring forward other data if required. You can comment out lines for fields that don't need to be exported to speed things up a little or to avoid updating fields that you don't want to be changed. A new addition exports album artwork into a folder where the script is and will insert artwork during the import phase unless the track already has art.

See this thread at Apple Support Communities for more details.
ExportImportPlays As ExportImport but only exports Plays and Skips. Can be used to restore played/skipped counts from a recent .itl file in the Previous iTunes Libraries folder in the event that iOS 8 caused these to increase too quickly.
ExportImportRaings As ExportImport but only exports Ratings. Can be used to restore ratings counts from a recent .itl file or a previously taken snapshot of your ratings created with this script.
ExportM3U Exports the selected tracks or current playlist as an M3U playlist file. Replicates an iTunes feature for when it isn't working correctly. Output will go to the same folder that the script is in, or you can edit a variable to set an output folder.
ExportM3ULists Exports the selected playlist, playlist folder, or entire library as individual playlists. Smart playlists and folders can be selectively included or excluded by adjusting flags in the script. As with ExportM3U the output files will go to the same location as the script or a nominated folder you define by editing the script. Empty lists, or those that only contain invalid items (cloud content, PDFs, iTunes LPs, etc.) will be ignored.
ExportToFolder Exports selected tracks to a folder with filenames based on a user defined pattern. Current keywords that will be replaced in the pattern are <Album>, <AlbumArtist>, <Artist>, <Composer>, <DiscNumber>, <Genre>, <Grouping>, <Index>, <Name>, <TrackNumber> & <Year>. The file extension is included automatically. Your pattern can include, for example, "\", "-", or " " as separators between keywords, where a "\" will create an additional subfolder. Index can be used as a four digit prefix when exporting playlists to ensure that the tracks can be played in sequence from their folder without using a playlist file. Track numbers are padded to two digits, or more if the track count suggests it. Standard export path (Root) and pattern can be stored in variables in the script for easy reuse.
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.
FindFiles 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 by locating a unique file of the same size in target folder and its subfolders. This alternative to FindTracks may take a long time to scan a large media folder without providing feedback to show it is still running.
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 by predicting the path the file should be at and fuzzy matching on file and folder names.
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.
FoundTracks Scans all tracks of the Library for those files that iTunes can find and adds them to a playlist called Found. Use in conjunction with a smart playlist called Lost consisting of the rule Playlist is not Found, to identify missing files within the library.
GaplessToPlaylist Scans selected tracks or the current playlist for Gapless tracks and, if found, adds them to a playlist called Gapless.
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.
HasLyricsToPlaylist Scans selected tracks or the current playlist for tracks with lyrics and, if found, adds them to a playlist called Has Lyrics.
ImportDevicePlaylists Imports regular playlists from an iPod or iOS device into the iTunes library. Can import from a selected playlist, or playlist folder, or all playlists on the device. Where the tracks on the device were added from a different library than the one being used for the import the script can scan the entire library and attempt to match tracks based on tag properties.
ImportFolderStructure Drag & drop an folder onto this script to import it into your iTunes library and create nested playlist folders to show the structure of the imported files. The same set of folders can be reimported as required when new content has been added without generating duplicates, although files that have been moved won't be removed from existing playlists. The current version also imports any M3U files that may be present arranging these in folders to match the structure on disk.
ImportFromXML Drag & drop an XML playlist onto this script to import play/skip counts/dates that were not imported by iTunes when importing an XML playlist. Attempts to match content in the library with the <Artist>\<Album>\## <Name> part of the file path stored in the XML so may be able to work with content that is now at a different path that it was when the XML was generated. The script could potentially be modified to import other metadata.
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, or one that has the same file at more than one location in the list.
InterleaveLists Adds tracks from two or more playlists alternating with a random track from each in turn. A source list can be named more than once. E.g. using "Blues\Blues\Jazz" as the source list would add two random tracks from the Blues playlist, then one from the Jazz playlist, then two more from Blues and so on. The script will stop adding tracks to the output list when one of the source lists has been exhausted or a pre-defined limit is reached.
iTunesAlbumList Produces a text file listing music albums in the library. This script can take some time to work through a large library and in its current form has no progress indication. The output file will open when the script has finished.
iTunesInfo Lists some library statistics and 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.
iTunesITLPath Reveals the path to the active iTunes ITL file found by searching the folder containing the XML.
iTunesXMLPath A simple script that reveals the path to the active iTunes XML file. The active <iTunes Library>.itl database will be in the same folder.
KeywordsToAlbum As KeywordsToComments, but changes are made to the Album field. New words are appended and separated by a space.
KeywordsToAlbumArtist As KeywordsToComments, but changes are made to the AlbumArtist field. New words are appended and separated by a space.
KeywordsToArtist As KeywordsToComments, but changes are made to the Artist field.

To replace the current value of Artist by AlbumArtist, for example, use the input: -<Artist> <AlbumArtist>

To swap values use two related scripts and a field you don't need as a temporary location or use/adapt one of the dedicated SwapFieldField scripts below.
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: <Album>, <AlbumArtist>, <Artist>, <Comment>, <Composer>, <Description>, <Disc>, <Genre>, <Grouping>, <Location>, <Lyrics>, <Name>, <Show>, <SortAlbum>, <SortAlbumArtist>, <SortArtist>, <SortComposer>, <SortName>, <SortShow>, <Track>, and <Year>. Disc and track numbers are padded out with leading zeros if needed to match the width of the disc or track count.

You can also use \n to insert a new line where the field supports it.
KeywordsToComposer As KeywordsToComments, but changes are made to the Composer field.
KeywordsToDescription As KeywordsToComments, but changes are made to the Description field.
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 alphabetically, 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.
KeywordsToShow As KeywordsToComments, but changes are made to the Show field.
KeywordsToSortAlbum As KeywordsToComments, but changes are made to the SortAlbum field. Use, for example, to append replace the current sort album value with one based on other properties, e.g. use -<SortAlbum> <Artist> <Year> <Album> to sort on the basis of artist, then year, then album title.
Kill@Files Removes files of the form <normal filename>@<32 hex digits>.<ext> recursively from within a selected folder. See this thread for background.
KillDeadTracks Check for items that cannot be found and delete the dead references from the library. Note if these might be duplicates of tracks that you do have it may be preferable to use the DeDuper script which can merge ratings, play counts and playlist membership before removing the dead link. Use a view or selection that excludes content from the cloud, e.g. a smart playlist with the rule 'Location is on this computer'.
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 playlists to be created if you attempted to add new tracks to your library by scanning the entire media folder and there were .m3u playlist files in the imported folders. I recommend using iTunes Folder Watch for the task of adding new tracks and removing orphaned entries if you want to work directly with the media folder outside of iTunes.
KillIndexedPlaylists Removes playlists that end with an index number that may have been created by a syncing bug that duplicates existing lists. Currently set to process smart lists to include Genius playlists.
KillNamedPlaylists Removes playlists based on partial match with name. E.g. enter Test to match with Test, Test 1, Testing etc. Will remove both smart and regular playlists.
KillSelectedFiles Deletes selected files from iTunes and also deletes the underlying files whether they are inside the iTunes Media folder or not. Files on local drives should be sent to the recycle bin, files on network drives are deleted outright. Better be sure before you let this one start work.

The current build won't handle iTunes Extras, iTunes LPs or video files that exist in both HD & SD versions properly, however these are unlikely to be located outside of the iTunes Media folder so, should the need arise, these can usually be disposed of in the normal way.
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 (removed in iTunes 12.4) this script also resets the Last Played & Last Skipped dates to Never, and resets any stored Bookmark Position. See also ResetPlayedDate and ResetPlays.
LocalizeM3U Drag & drop an M3U or M3U8 playlist onto this script to change the absolute path references to pointers to files in the same folder as the playlist 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. This script removes all parent folders in the path leaving just the filename for each file referenced by the playlist.
See also RelativeM3U.
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.
ModifyLastPlayed Set or update Last Played values for selected tracks or the current playlist. Use the format [+/-]dd/mm/yyyy hh:mm:ss where a leading +/- indicates an offset, otherwise the absolute date and time to set. Digits are optional and you don't have to fill in the entre string. E.g. -10 will take away 10 days from existing values, +// 1 would add an hour, and 2/3/23 would make it appear that the tracks had been played in sequence starting at midnight February 3rd, 2023.
NameToTag Force Tunes to update Name field in the tags of selected tracks by adding * to the value and then removing it.
PlaylistsToFile Creates a text file containing the names of all the playlists in the iTunes library, indented to show folder structure.
PlayTheList Script to play a named playlist, typically on start up. Edit and replace <ThePlaylist> with the name of the list you want to play. Save a shortcut to the script in your startup folder or create a task to run it.
RefreshSmartPlaylists Refreshes the contents of all smart playlists that have random selection criteria. Could be edited to apply only to a limited group of named playlists. Aimed for use in a batch file to avoid having to manually select and delete tracks from smart playlists to refresh them.
RelativeM3U Drag & drop an M3U or M3U8 playlist onto this script to change the absolute path references to relative pointers to files in artist & album folders below the folder containing the playlist file. This script preserves two layers of parent folders in the path for each file referenced by the playlist.
See also LocalizeM3U.
ReplaceTextInAlbum Replaces instances of one set of characters with another. Call the script and enter your search and replacement text. Surround the search and replacement text with spaces to ensure a match with whole words.
ReplaceTextInAlbumArtist As ReplaceTextInAlbum, but changes are made to the AlbumArtist field.
ReplaceTextInArtist As ReplaceTextInAlbum, but changes are made to the Artist field.
ReplaceTextInName As ReplaceTextInAlbum, but changes are made to the Name field.
ResetAlbumAutoRating Restores normal Album AutoRating behaviour after using ClearAlbumAutoRating.
ResetPlayedDate Reset played date only of selected tracks. Compare with LastPlayedNever which makes it appear that a track has never been played or skipped, and removes any bookmark position.
ResetPlays Reset play count only of selected tracks. Compare with LastPlayedNever which makes it appear that a track has never been played or skipped, and removes any bookmark position.
ResetStartEndTimes Resets start time if greater than zero and end time if less than the song length.
ResetTrackAutoRating Restores normal Track AutoRating behaviour after using ClearTrackAutoRating.
SelectionOrderToTrackNo Sets sequential values for Track Number based on the play order of selected tracks within a playlist.
SetDiscCount Sets the Disc Count for selected items. To be used with iTunes 12 when the Disc Count field is not available in Get Info, e.g. for Books, Movies or TV Shows. Note setting either Disc Count or Disc Number to something other than zero allows both to show in Get Info.
SetDiscNumber Sets the Disc Number, and optionally Disc Count, for selected items. To be used with iTunes 12 when the Disc Number/Disc Count fields are not available, e.g. for Books, Movies or TV Shows.
SetDiscTrackCounts Sets the total Disc Count for each album and the total Track Count for each disc within it. Blank disc numbers are set to Disc 1 of 1. Should be applied to complete albums, or at least to all tracks that you have for each album that is included in the selection. Tracks with no valid artist, album, or track number are ignored. Counts are set the to largest disc/track count/number of the relevant items.
SetLastPlayedByAlbum Working with the current playlist or a selection of tracks, sets the Last Played date/time for each track from the same album so that it will appear that each album has been played through from start to finish in order. Tracks with no valid artist or album are ignored. An optional parameter change allows the script to set Last Played to the minimum, maximum, mid (of min and max), mean average value, median average value, or set the date & time for each album manually. The script is currently set up for manual mode.
SetSkipOff Sets Skip When Shuffling to Off for selected items. Use where this flag cannot be controlled via Get Info.
SetSkipOn Sets Skip When Shuffling to On for selected items. Use where this flag cannot be controlled via Get Info.
SetTrackCount Sets the Track Count for selected items. To be used with iTunes 12 when the Track Count field is not available in Get Info, e.g. for Books, Movies or TV Shows. Note setting either Track Count or Track Number to something other than zero allows both to show in Get Info.
SetTrackNumber Sets the Track Number, and optionally Track Count, for selected items. To be used with iTunes 12 when the Track Number/Track Count fields are not available, e.g. for Books, Movies or TV Shows.  See also EpisodeNoToTrackNo and UpdateVideoDetails.
SetVideoKindMovie Sets the internal VideoKind property of selected tracks to MovieVideoKind, which may not happen when setting Media Kind through Get Info, and may affect the way iTunes organizes the media files.
SetVideoKindMusic Sets the internal VideoKind property of selected tracks to MusicVideoKind, which may not happen when setting Media Kind through Get Info, and may affect the way iTunes organizes the media files.
SetVideoKindTV Sets the internal VideoKind property of selected tracks to TVVideoKind, which may not happen when setting Media Kind through Get Info, and may affect the way iTunes organizes the media files.
SetVolumeAdjustment Sets the internal Volume Adjustment property of selected tracks to your chosen value in the range -100% to 100%.
SetYear Sets the Year of selected tracks from the release date or manual input. N.b. At the time of posting iTunes suppresses any date earlier than 1601.
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.
SortTrailingDigits Pads out any trailing digits from Name into Sort Name in order to achieve sensible sorting for tracks with identical names apart from a trailing index number. The script currently pads to 4 characters but can be edited if required.
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, also swaps the corresponding sort values.
SwapAlbumName Swaps values between the Album & Name fields.
SwapArtistAlbum Swaps values between the Artist & Album fields.
SwapArtistAlbumArtist Swaps values between the Artist & AlbumArtist fields.
SwapArtistName Swaps values between the Artist & Name fields.
SwitchLinks Switches links from files in one media folder to matching files in a parallel media folder. Use when files have been copied first rather than being consolidated and/or are in a non-standard layout.
SyncStats Copies highest play count, skip count, rating and most recent played & skipped date of selected tracks or playlist between iTunes and a manually managed iPod/iOS device. Will attempt to match tracks first on LibraryIDs and if that fails on tracks with the same tag information. See also CombineStats. Can optionally import volume adjustments from device (set GetVol=True).
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)
A macOS version of this script for Music on macOS Catalina or later is available here.
TagFromName Updates Track No, Artist and Name from a track name in <Track> - <Artist> - <Name> form, or Artist and Name if the name is in the form <Artist> - <Name>. Leading zeros and spaces around the dash following any track number are optional.
TitleCase Convert Album, AlbumArtist, Artist, Composer, Name & Show fields to Title Case. There are some extendable exception lists to force particular words to match your desired style, and options to select which fields are updated.
TrackNoToEpisodeNo Copies values from the Track Number field to the Episode Number field of selected tracks or all tracks in the current playlist.
TrimmedToPlaylist Scans selected tracks or the current playlist for trimmed tracks, i.e. those with adjusted start or end times, and if found adds them to a playlist called Trimmed.
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.
TweakPlays Display and optionally edit the current play count value of selected tracks one at a time.
UnAutoSort Sets  Sort Album, Sort Album Artist, Sort Artist, Sort Composer, Sort Name, and Sort Show fields which begin A/An/Then to override the AutoSort feature of iTunes for selected tracks or all tracks in the current playlist. See also AutoSort above. Optionally fill in all sort values by setting the variable ForceSort=True.
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.
UpdateVideoDetails Copies season and episode numbers into disc and track numbers for selected TV Shows.
   
Note #1
Media Organisation
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. Otherwise, if iTunes is organising the files and they are located inside the media folder, iTunes will simply undo any changes made by these scripts.

Note #2
Progress Bar
Many of my scripts include the provision of a progress bar. The script will do its job quite effectively with or without a progress bar but when processing large numbers of files it is nice to be able to see that it is still working and get an idea of how long it will be before it finishes. Unfortunately the code to create and control the progress bar uses a feature of Windows where one program (my script) is allowed to control another (an instance of Internet Explorer). Security features introduced in Windows Vista break this method. I don't have the resources to develop or purchase an alternative progress bar control that is compatible with UAC so the easiest approach, at least from my point of view, is to detect if UAC is active and suggest that you disable UAC if you want to see a progress bar while running the script. You can reset UAC later.

How to disable User Account Control

... So Windows 8 came out, and it has broken things again. With Windows 7 and Vista turning off the User Account Control feature (UAC) allowed the script to talk to the instance of Internet Explorer that it had created. What I hadn't realised before was that this was due to a side effect of that setting which also disabled a policy flag called EnableLUA. It is Limited User Account (LUA), when enabled, that blocks the communication between the script and the progress bar, but in Windows 8 UAC and LUA are no longer completely tied together. Turning off UAC is a control panel adjustment. Turning off LUA independently of UAC requires diving into the registry. To make things easier I've added another script EnableLUA that reports the current state of the policy setting and allows the user to change it. An unwanted side effect on Windows 8 is that with LUA disabled none of the Metro apps will work. Not sure why they could not have remained working and sandboxed even if the user requires a more relaxed policy for their legacy code, but there it is.

Windows Scripting Host If your browser opens the scripts as text files return to the previous page, right click on the link and click Download... or Save link as... or whatever variant your browser offers. Alternatively if your browser or anti-virus software blocks the download but allows you to view the text then copy the text and save it as a new text file with a .vbs extension or edit the file extension from .txt to .vbs after saving.

If the downloaded scripts open as text files then you may need to install the Windows Scripting Host:
Windows Script 5.7 for Windows XP
   
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. You may also want to make a copy of your current iTunes Library.itl file (add it to the Previous iTunes Libraries folder with the current date) in case there is any need to try to reverse any of the changes you've made with a script.