dougscripts.com

Managing Tracks

November 22 2019 - 1:03 pm

UPDATED: Copy Tracks to Multiple Playlists v5.0

For macOS 10.15 Catalina and later only. This script will copy the selected tracks to one or more chosen playlists.

Also see Remove From Other Playlists.

More information for Copy Tracks to Multiple Playlists v 5.0 and download link is here.

November 22 2019 - 1:03 pm

UPDATED: Comments Search v2.0

For macOS 10.15 Catalina and later only. This script will search the Comments tags of the Music library tracks for a user-entered text string and copy the track results to a discrete playlist.

More information for Comments Search v 2.0 and download link is here.

October 16 2018 - 12:51 pm

Unfinished TV Shows

The TV Shows library can show you Watched shows and Unwatched shows. And how much time is left in shows you've started. But there's no way to sort these unfinished tracks or gather them all together, say, with a Smart playlist rule.

So here's a script that will find TV Show tracks that haven't been played all the way through and copies them to a new appropriately named playlist:

property tvPlaylistName : "_Un-Finished TV Shows"

tell application "iTunes"

set tvLib to (get some playlist whose special kind is TV Shows)

-- delete any old playlists

if (exists playlist tvPlaylistName) then

delete (every playlist whose name is tvPlaylistName)

end if

-- recreate, add date in playlist description

make new playlist with properties {name:tvPlaylistName}

tell playlist tvPlaylistName

set description to date string of (get current date)

end tell

-- examine each TV track

repeat with i from 1 to (count tracks of tvLib)

try

set aTVTrack to track i of tvLib

if (bookmark of aTVTrack) > 0.0 then

duplicate aTVTrack to playlist tvPlaylistName

end if

end try

end repeat

end tell

Open this in Script Editor by clicking the little little script icon above. Save it named whatever you like with the Format "Script" (.scpt) in your ~/Library/iTunes/Scripts/ folder so that it will be listed in the iTunes Script menu.

This script will need to be run manually every so often in order to refresh the playlist. Follow the instructions on this page to add a keyboard shortcut.

For Smarties: tracks in other libraries use the bookmark property (some by default) as well. Podcasts, Movies and Audiobooks can be sorted using a smilar script that targets those special kind libraries.

January 13 2018 - 11:06 am

Segregate Shufflable Tracks

A Correspondent queries:

"Do you have a script that can create a playlist of songs if they have the "Skip when shuffling" attribute ticked in the info panel? The reason is because when I sync those songs to the iPhone that feature doesn't sync along with it so they play regardless. The feature works on the Mac, just not on the iPhone."

The shufflable property of a track does not have a corresponding Smart playlist criterion or Songs view column. So, looks like the only way to identify these tracks en masse is with AppleScript.

Interestingly, the shufflable property works somewhat backwards. If the "Skip when shuffling" checkbox is set (and a checkbox when checked has a "true" value) the corresponding shufflable property is set to false; that is, "not shufflable". This might be the opposite of what you'd expect. For instance, when "Remember playback position" is set to true with a checkmark, its correponding bookmarkable property is set set to true (yes, allow this track to be bookmarked). Just kind of interesting. A little. But its important to keep in mind when you want to detect the correct (and not opposite) value.

Anyway, here's a script that will copy any tracks in the Music library set to "skip when shuffling" to an existing playlist:

tell application "iTunes"

set targetPlaylist to playlist "Skip Shuffle Tracks"

set musicPlaylist to (some playlist whose special kind is Music)

set theTracks to every track of musicPlaylist whose shufflable is false

repeat with aTrack in theTracks

set db to database ID of aTrack

try

if not (exists (get some track of targetPlaylist whose database ID = db)) then error

on error

try

duplicate aTrack to targetPlaylist

end try

end try

end repeat

reveal targetPlaylist

end tell

Open this in Script Editor by clicking the little script icon. Save it named whatever you like as a Script Bundle in your ~/Library/iTunes/Scripts/ folder so that it will be listed in the iTunes Script menu. I have already created a playlist in iTunes named "Skip Shuffle Tracks" so make sure you do, too. if you want to use a playlist with a different name then you will have to hard-code that name in the script where I have used "Skip Shuffle Tracks".

Whenever you run the script it will get a list of track references from the Music playlist where each has its shufflable set to false. It will iterate over this list and for each track it will first see if the track already exists in the target playlist; and if it does not the track will be copied to the playlist.

The second try block around the duplicate command ensures that if any track cannot be copied, such as a "dead" track, the script will skip it without erroring.

November 27 2017 - 10:40 am

Internet Radio Streams Playlist

I recently swapped receivers (or, I should say, amplifiers) in my office. I was using a decent mid-priced Sony receiver to power two zones of speakers: a set of Bose 301s and a "near-field" set of cheap desktop speakers and sub-woofer. I replaced it with an unused Onkyo amp I had purchased a few years ago. As a result of the switch, I no longer have a radio tuner in the configuration.

But, as it turns out, I don't need one. I'm lucky enough to have all the local Boston-area stations I listen to available in the Internet Radio section of iTunes. I never paid much attention to them before since I had a receiver. This gives me some nice advantages:

  • Internet radio feeds seem to precede the part of the broadcast audio chain where the signal has the life processed out of it. I no longer have to tolerate crappy broadcast audio.
  • Almost all my music sources are available digitally in one application, iTunes. Pandora is the only audio service I use requiring another app, but I mostly listen to it on mobile.
  • I can AirPlay iTunes all over my house.

The only downside so far is that I can't listen to live local play-by-play sports broadcasts because, for various "contractual obligations", these broadcasts can't be internet-'casted.

One quibble I've always had with iTunes Internet Radio is that it's not exactly easy to manage the stream tracks. Finding them in the Radio list can be a chore and sometimes stations will disappear and the re-appear with a different URL. There's not much I can do about either of those issues.

But to make life a little easier, I have created a "__Radio" playlist to which I have dragged the stream URLs I regularly listen to. I've also create a little script to quickly pull up the __Radio playlist with a keyboard shortcut:

tell application "iTunes" to reveal playlist "__Radio"

I've assigned Option-Command-R as a keyboard shortcut to the script.

One other thing I've done is to store the URL address of each stream track in the __Radio playlist. I grab the address property of each URL track and then paste it into a text document for safe keeping:

Later, if necessary for any reason, I can open the address with something like this:

set theStream to "https://audio.wgbh.org/otherWaysToListen/wgbh.m3u"

tell application "iTunes" to open location theStream

This will create a new URL track in a playlist called "Internet Songs". I then drag the track to my __Radio playlist and usually delete the "Internet Songs" playlist, although keeping it around isn't a bad idea either.

June 1 2016 - 9:17 am

NEW: Reset Plays

Even though I had posted a script workaround to emulate the now-removed "Reset Plays" feature, several users had suggested adding a few additional settings. Plus, some people were just not sure how to get that script onto their machines.

Reset Plays is a downloadable variation of that original script that, in addition to resetting Plays and Played Date, also resets Skips, Skipped Date, Rememebr Playback Position and the played property.

August 3 2015 - 10:37 am

UPDATED: Search Results to Playlist v2.1

Search Results to Playlist can search a chosen category (Library, Music, Movies, etc) or the selected playlist for user-entered text by All, Song, Artist, Album, or Composer tag and copy the track results to a Search Results playlist, which will be created automatically if necessary.

Search Results to Playlist

It can optionally re-create or append to the Search Results playlist on each run. Floats over iTunes while active for easy access.

This latest version has some minor fixes for compatibility with iTunes 12.2+ and accommodations for OS X 10.11 beta.

More information and download is on this page.

June 25 2015 - 6:47 am

Script of the Day: Search Results to Playlist

Search Results to Playlist can search a chosen category (entire Library, Music, Movies, etc) or the selected playlist for user-entered text by All, Song, Artist, Album, or Composer tag and copy the track results to a Search Results playlist, which will be created automatically if necessary.

Search Results to Playlist

Can optionally re-create or append to the Search Results playlist on each run. Floats over iTunes while active for easy access.

More information and download is on this page.

Previous Scripts of the Day. Subscribe to my RSS feed or follow @dougscripts on Twitter to get daily "Script of the Day" notifications.

June 5 2015 - 6:28 am

Script of the Day: Search Results to Playlist

Search Results to Playlist will search a chosen category (Library, Music, Movies, etc) or the selected playlist for user-entered text by All, Song, Artist, Album, or Composer tag and copy the track results to a Search Results playlist, which will be created automatically if necessary.

Search Results to Playlist

It can optionally re-create or append to the Search Results playlist on each run. Conveniently floats over iTunes while active for easy access.

More information and download is on this page.

Previous Scripts of the Day. Subscribe to my RSS feed or follow @dougscripts on Twitter to get daily "Script of the Day" notifications.

May 20 2015 - 5:57 am

Script of the Day: Copy Tracks to Multiple Playlists

Copy Tracks to Multiple Playlists will copy the selected tracks to one or more chosen playlists.

Copy Tracks to Multiple Playlists

More information and download is on this page.

Previous Scripts of the Day. Subscribe to my RSS feed or follow @dougscripts on Twitter to get daily "Script of the Day" notifications.

Site contents © 2001 - 2024 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not be interrupting the one who is doing it.