Have a Happy New Year
Updated Mono-Stereo Toggling
Apple changed a few things in System Preferences under Mojave which broke this script to toggle between Mono and Stereo output.
Here is the fix. You will note that it is a simple change to the line targeting the System Preferences' Accessibility window.
tell application "System Preferences"
reveal anchor "Hearing" of pane id "com.apple.preference.universalaccess"
end tell
tell application "System Events"
tell application process "System Preferences"
set frontmost to true
tell group 1 of window "Accessibility"
# pre-Mojave - replace the line above with the one below
# tell window "Accessibility"
set monoStereoCheckbox to checkbox "Play stereo audio as mono"
if (get value of monoStereoCheckbox) as boolean is true then
set ddMessage to "Switch to STEREO output?"
else
set ddMessage to "Switch to MONO output?"
end if
if button returned of (display dialog ddMessage buttons {"No", "Yes"} default button 2) is "Yes" then
tell monoStereoCheckbox to click
end if
end tell
end tell
end tell
if application "System Preferences" is running then
tell application "System Preferences" to quit
end if
For more details, read the original post.
Dupin Lite 2 v1.4.0 Now at Mac App Store
Dupin Lite 2 has been updated to version 1.4.0 and is now available on the Mac App Store.

Dupin Lite 2 is a "lighter" version of my iTunes duplicates-managing app Dupin. It has fewer power-user features and essentially gets right to the business: find dupes, filter for Keepers, Purge.
This latest version accommodates Dark Mode under Mojave and adds some performance enhancements.
Idle Wish List
Dear iTunes Santa,
It would be great if clearing Up Next could be done via AppleScript.
Also, I have wanted to
tell application "iTunes"
make new playlist window with properties {view:playlist "Mom's Favorites"}
end tell
for a long time.
I have been a good boy.
Mojave Update Updates iTunes
The latest macOS 10.14.2 Mojave update also evidently updates iTunes to version 12.9.2.5 and I have questions.
The previous version of iTunes was 12.9.0.164. Was there ever a 12.9.1.x release? I never had it.
Speaking of version 12.9.0.164: it was originally part of one of the Mojave betas and then installed by the final release of Mojave 10.14. Is there no stand-alone installer for this version?
Is there a stand-alone installer for version 12.9.2.5?
Is this how we are to get iTunes updates now? Via operating system updates? If so, why? And isn't it rather extraordinary?
UPDATE (December 8, 2018, 1:02PM): This Apple doc declares "iTunes comes bundled with macOS. To get the latest version of iTunes, update the software on your Mac". And "If you can’t update to macOS 10.14 Mojave, you might still be able to get some updates for iTunes (up to iTunes 12.8)." (h/t Peter Cook.)

Shortcuts and SSHing to Snow Leopard
Like you-wouldn't-believe-how-many other people, I still run an old Mac Mini with Snow Leopard on it. It's been pretty reliable as an occasional music server and we still use it to play iTunes internet radio on AirPlay devices around the house. It also manages some backup tasks on my network. It runs headless and I access it through Screen Sharing when necessary.
It is more difficult then it used to be to remotely control Snow Leopard with AppleScript from newer operating systems. At one time, you could just address the machine and run commands with a username and password. Now you need to set up SSH. I haven't done that and just use Screen Sharing.
But, believe it or not, the Run Script Over SSH action I described earlier works with Snow Leopard out-of-the-box. I will now set about creating a batch of Shortcuts to be able to quickly manage stuff on the Mac Mini with AppleScript, like playing a parrticular radio station in iTunes, shutting music down, changing AirPlay devices and so on, which I can call from my iPhone. Pretty cool.
Scripting to a Mac with iOS Shortcuts
I'm not particularly bowled over by Shortcuts on iOS. I just don't use my iPhone and iPads rigorously enough that I'm inspired to automate many tasks. But I get that it's a thing.
What I find very interesting however is that you can use Shortcuts to launch AppleScripts on a targeted Mac. So, while the "Music" actions on iOS are somewhat limited, there's actually some potential usefulness in calling scripts (via Siri, even) from your iOS device to control iTunes on a Mac.
A nice basic tutorial by the great folks at Late Night Software explains how set this up. Essentially, you use the Run Script over SSH action to enter an osascript command to launch a script on a specified Mac. If you've ever done anything with launchd then you will recognize some similarities.
There are some limitations. First, AppleScript does not run on iOS. So anything you want to do with this technique will necessarily be on one particular Mac. (While I can imagine that it is possible to run other SSH commands from that Mac to other Macs, making all of that swing is beyond the scope of this article.)
Second, I am working strictly with scripting iTunes on a Mac. Many other apps on your Mac can be controlled with AppleScript, too.
Third, there is limited opportunity for user-interaction and feedback. (Depending on the use case, it is possible to manage some simple back-and-forth user-interaction in Shortcuts. But, again: beyond, scope, article.)
So, considering those parameters, there aren't many iTunes track and playlist management things I'd want to do remotely; I'd prefer to be operating on track info while sitting in front of iTunes. But we can still use Shortcuts to perform some serviceable tasks with iTunes remotely, things that can't be done conveniently with the Remote app on iOS.
Below, I describe how to create some Shortcuts that can launch scripts on your Mac. One will save the currently playing track to a "Favorites" playlist, another to change the AirPlay configuration and, lastly, one that pauses iTunes for five minutes. These may give you ideas for your own Shortcuts.
Some More About Re-Ripping
After my last post about re-ripping CDs, it occurred to me that I should do some re-ripping myself. So, as discussed in the post, I was able to confirm that iTunes does warn you about tracks you've already ripped (tracks with the same Song Name, Artist and Album) and then offers to "Replace Existing".
However, it only tells you this after you've engaged "Import CD" and advanced past the encoder settings dialog. I would much prefer to be aware of these tracks and any potential anomalies before engaging the rip so I can make any alterations to accommodate more efficient ripping. For instance, what file type, bit and sample rates are these already ripped tracks? How many of them are there? Are there any duplicates?
(Another good question is: Did I change the metadata of any tracks I previously ripped from this CD? Those will be harder to find, especially if the Album and/or Artist tags have been changed; iTunes will not consider those tracks a match for any on the CD. The tag info could have been changed by your own hand, or, if it's been several years since you've inserted the CD, Gracenote could have supplied different tag info. I've had this happen.)
Since I know iTunes will offer to "Replace Existing" if it finds library tracks with the same Song Name, Artist and Album I will want to see any of those. And here's a script that tries to find them and offers to wrangle them into a discrete playlist for further investigation:
Re-Ripping FYI
Those of us who may still rip/re-rip a CD or two in iTunes from time to time may see this dialog:

I heard from a user today who wanted to replace a bunch of MP3s with new Apple Lossless copies. But he was afraid that selecting to "Replace Existing" would erase the tags he had meticulously created for the original MP3s.
iTunes uses the Song Name, Artist and Album of each CD track and looks for a track in the iTunes library with tags that match. If a match is found, then you will see the dialog above. And then if you select to "Replace Existing", you are essentially replacing the file and not the track entry itself; that is, the newly ripped-CD track's file replaces the original MP3 file pointed to by the track entry and the other track entry data remains the same (except for obvious changes due to the change of file, like size and file kind and so on).
If one or more of the Song Name, Artist and Album is different then you won't be asked to replace any tracks and the CD tracks will be imported as "new" tracks, perhaps as duplicates.
Rather than allow iTunes to make these decisions, here's a trick. Before importing, copy some tag data from the original tracks in the library to the corresponding CD tracks using Copy Tag Info Tracks to Tracks.

You probably only need to copy Song Name, Artist and Album. But any additional tags wouldn't hurt either.
(Also, see this article at the German site unhyped.de which describes the technique as well.)
Then, when you import the CD, you'll probably now see the "already been imported" dialog from whence you can select "Replace Existing" to correctly replace the original files and keep the existing track entry data.
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.

