November 14 2018 - 2:13 pm

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 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.

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)


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.

October 12 2018 - 4:02 pm

Tab Amongst Buttons

A Twitter denizen inquired how to be able to tab between two or three button in a dialog instead of having to use the mouse to click the one in particular.

Go to System Preferences > Keyboard > Shortcuts. At the bottom you will see a setting for “Full Keyboard Access”. Click the button next to “All controls”. Afterwards, you’ll notice that selected buttons will have a focus ring. You’ll probably notice some other UI elements will have focus rings, too. Which is why I only toggle it on (Control-F7) for testing. It’s a bit too distracting for regular use at my house.

I mention this as a tip because many of my scripts use two or three buttons and if you are mouse-averse and keyboard-loving then it should be a treat.

October 8 2018 - 12:18 pm

Trimming iTunes Audio With Quick Look

Mojave introduced some interesting contextual editing features to Quick Look. Quick Look was already handy for viewing disparate types of files in the Finder by pressing the Space Bar while a file was selected. Now, depending on the type file being viewed in Quick Look, various editing widgets will be made available.

I was very surprised when Apple first demo’d Quick Look in Mojave and saw that audio editing was a possibility. Albeit, it’s just simple trimming—that is, audio can be removed from the beginning and/or ending of an audio file—but it might prove handy.

A few years ago I posted an AppleScript wrapper for the qlmanage command line tool, called Have a Quick Look. It allows you to select a track in iTunes and display a Quick Look panel of the selected track’s file. A trifle, really.

But now that Quick Look has this new editing feature, Have a Quick Look could be a slightly handier tool. Here is a track from one of my “Live At Leeds” albums by The Who, which I have selected in iTunes and then run Have a Quick Look on. Pete Townshend famously talks a lot before each song. Now, I can trim that part out (sorry, Pete):

You can see the :40 seconds of Pete pontificating at the start of the track

Optimally, this sort of editing should be done with a Real Audio Editor. But if you’re just fixin’ Voice Memos (which can be added to iTunes by dragging from the Marzipan Voice Memos app) or something like that, I suppose this could be helpful.

September 24 2018 - 2:31 pm

Toggle Dark Mode

A variation of this has been around since the first beta, but what the heck:

tell application "System Events"

tell appearance preferences

set dark mode to not dark mode

end tell

end tell

Save it in Script Editor named “Toggle DM” (or whatever) and select “Application” as the File Format, which makes it activate by clicking on it in the Finder. I recommend putting it in the Dock or Finder window toolbar for quick access.

September 24 2018 - 12:37 pm

Updates for Mojave

As I mentioned last week, I have been updating scripts and apps for Mojave on a piecemeal basis. There are a good forty or so scripts now ready for Mojave Monday and the apps Dupin v2.14.2, M3Unify v1.11.1 and Join Together v7.8.2 have received initial updates for Mojave.

Mojave-ready scripts will explicitly state that they have been updated for Mojave. Otherwise, most scripts that can run on macOS 10.10 and later will likely be fine in 10.14. Except for being ignorant of your Dark Mode settings. And perhaps other very minor and benign incompatibilities.

Also, as I mentioned, the first time you run any apps or scripts of mine in Mojave you will be asked to “OK” access to iTunes.

If you click on “Don’t Allow”, you will need to visit System Preferences / Security & Privacy / Privacy and re-authorize the script.

I will continue to be cranking out updates over the coming days and weeks.

September 11 2018 - 9:33 am

What About Dark Mode?

I wasn’t rooting for a Dark Mode, the new low-light display preference in macOS 10.14 Mojave. And after working in it I don’t particularly care for it. But I get that many people will find it compelling. So I’m guessing that there are a few “Dark Power” users who will expect that the scripts they download from this site will work in Dark Mode.

Well, they won’t. Not all yet, anyway. In order for AppleScript apps and scripts to respond to Dark Mode they have to be built in Mojave. Anything built in prior operating systems won’t know about Dark Mode. Now, other than updating the scripts just for Dark Mode, there aren’t enough compatibility issues that necessitates a script to be updated yet (new security features, notwithstanding). Most all have been testing fine under the macOS 10.14 betas. So, in my opinion, there’s no rush.

That said, there are some scripts and apps I will be updating for Mojave sooner than later, and these will include some of the more popular shareware apps and scripts. And then, eventually, as more scripts require regular maintenance they will be updated as a matter of course.

September 10 2018 - 7:51 pm

Mojave Security

Most apps from this site are 1) saved as read-only to inhibit malicious code injection, 2) codesigned with my authorized developer ID so that they will break if they are so edited and 3) packaged in a disk image that is also codesigned with my developer ID so that the disk image will not open if its contents doesn’t check out. You—the user—also have Gatekeeper security options to allow just Mac App Store and/or developer signed apps.

Additionally, I would hope that my own personal reputation as a “good dude”, cultivated over almost twenty years as an AppleScript developer, would also attest to the safety of my scripts. But that won’t be the case for bad actors attempting to hijack processes on your Mac.

Apple is introducing a new level of security in Mojave called “AppleEvent Sandboxing”. It effects how AppleScript is or isn’t permitted to access certain locations and processes on your Mac.

When you launch an AppleScript of mine for the first time on macOS 10.14 Mojave you’ll see something like this:

This message will appear before the app or script starts runniing or it may appear a little later into the launch, if and when it actually attempts to access iTunes. AppleScripts that work with multiple apps will display an alert for each of those apps.

(Personally, I think that “OK” button should say “Allow”, but, whatevs.)

This is a new layer of protection that attempts to prevent AppleScripts, and other apps that use AppleScript, from controling apps and accessing data without you knowing about it. When you click “OK”, you’ve acknowledged to the system that you indeed intend to use the script with said application. Once so acknowledged, you shouldn’t see the dialog(s) again for that particular script.

Users of scripts that have targeted “System Events” may be familiar with this process when Accessibility requires a similar acknowledgement. This is a little different since it falls under the purview of Security & Privacy. In fact, if you go to System Preferences > Security & Privacy > Privacy > Automation, you will see the list of apps that use automation and which apps they target:

The list of apps on my machine is way longer than appear here.

If necessary, you can uncheck an app if you suspect the listed AppleScript is up to some funny business. Or, if you clicked on “Don’t Allow” when first asked, you can enable access for a particular app.

Felix Schwartz has posted some first looks at AppleEvent Sandboxing and it’s worth a read until Mojave is officially released and Apple tells us more.

September 2 2018 - 7:34 am

Airport Express Firmware Update

I use three Airport Express base stations each hooked up to class-D amp/speakers so we can have music around the house. And this past week Apple—surprisingly—released a firmware update for these discontinued devices that gives them support for AirPlay 2. AirPlay 2 eliminates any audio latency between devices that may be playing simultaneiously (such as a pair of HomePods used in stereo). While this wasn’t much of a problem at my house before the update—minimal latency was detectable occasionally and wasn’t too distracting—I can attest that there is zero detectable latency now.

The Airport Express is a great option for creating an AirPlay audio network and you can still find them being sold as refurbs, used on eBay and elsewhere. They aren’t exactly using modern WiFi or security protocols, but if this isn’t an issue at your house it may be an inexpensive way to wirelessly extend your audio system.

The “Kitchen Express” on top of our refrigerator.

August 17 2018 - 8:21 am

Dupin v2.14

I’m happy to announce the release of Dupin v2.14, which adds a couple of navigation features I found myself wanting.

In case you don’t know, Dupin works with iTunes to discover, manage and even remove duplicate tracks and files. But Dupin allows you a way to establish exactly what properties of tracks make them duplicates and to choose which single track of a “Dupe Group” of tracks is the “Keeper” and which are the “non-Keeper(s)”. The latter Filtering can be done automatically or manually by scrolling through the Dupe Groups.

Dupin is available to try in Demo Mode, whereby some features are limited. A registration code to unlock the Demo Mode is $15.00.

Dupin turns eleven years old this year and wouldn’t have stayed alive so long without such a great group of users. So thanks!

Site contents © 2001 - 2019 (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 interrupt the one doing it.