MacOS Automation: Accessing Academic Resources

Keyboard Maestro Textexpander.png

I shared an iOS Shortcut recently for opening academic journal articles via EZProxy. It’s a simple trick to short circuit the tedious cut and paste method . All it does is copy the EZproxy address 1 to the start of a url to give you access to resources via your own university library. Here are a couple of simple methods for doing the same thing using macOs automation tools.

Open Closed Access Journals with EZProxy and Keyboard Maestro

I am slowly coming to terms with some of the intricacies of macOS automation. Even so, I find Keyboard Maestro can be a little overwhelming at times. For one thing, it has a seriously misleading name, going well beyond the keyboard to hook into anything you could possibly want to do with macOs automation. The good news is you don’t have to be a coding grand master for it to be useful. This little macro is proof of that. Keyboard maestro can even simulate keystrokes, so using this method can even save you from hitting return.

macOS Automation Keyboard Maestro
Keyboard Maestro can simulate system shortcuts and keystrokes so one hotkey can do all the work

Automate EZProxy with TextExpander

Built in Macros come standard with any decent text expansion app. I’m still using TextExpander, simply because there are no alternatives on iOS. As good as it is, the fact that I have Alfred on hand means TextExpander could probably be made redundant on macOS.

To make this work with TextExpander use the builtin macros to both grab the system clipboard macro and simulate keystrokes. My snippet looks like this: %key:return%

Obviously, you need to copy the URL before you type the abbreviation so you’re a keystroke ahead with the Keyboard Maestro version, if that matters to you.

macOS Automation
TextExpander's builtin macros can add the system clipboardd to a snippet, simulate keystrokes, and more

Other Options

I already mentioned Alfred, which is easily as powerful as Keyboard Maestro. This would be a trivial problem to solve with Alfred, either by creating a workflow, or by using Alfred’s text expansion utility.

Another option is to use a clipboard manager. With Copied, for example, you can setup templates to transform the text you copy, and activate them with hotkeys. Similar functionality can be found in Pastebot. 2

  1. Most university libraries, and some public libraries have an EZProxy address, it shouldn’t be too difficult to find one you can access.
  2. Unfortunately, neither app has been updated in a while, so I can’t vouch for their longevity. Copied is still working perfectly for me on macOS Mojave

iOS Shortcuts: Clipboard Shortcut for Bibliographic Data

Ios Shortcuts Book Scanner.png

I recently shared an iOS Shortcut for scanning citations directly from the barcode of a book. Handy as it is, I have another shortcut I’m getting a lot of mileage from when I write on my Mac. Both Zotero, and Bookends 1 can add references to your library directly by scanning different metadata, including any book’s ISBN. You can obviously search for the numbers, or type them out by hand, but this little trick can add items to your library by using an iOS device as a scanner.

Zotero Quick Add.png
Zotero can add items to your library automatically using metadata, such as the ISBN

The shortcut works by scanning the ISBN from a barcode of any book and copying it to the clipboard.  If the Universal Clipboard is working properly, the ISBN will become immediately available on the nearest Mac to paste into Zotero, or Bookends. I have also set it to copy the number to my clipboard manager in case the universal clipboard fails, as it does far too often 2.

This version of shortcut is configured to use my favourite clipboard manager, Copied. You could also use the equally impressive Paste, which is included with Setapp. Or any other app  with a URL scheme that uses iCloud sync, like Gladys or Yoink. You could even use Apples own Notes App in a pinch.

Download the shortcut and adapt it to your needs here: IBSN Scan To Copied


  1. These are the two I recommend, but other reference managers will do this too 
  2. I have lost hours troubleshooting the universal clipboard when it stops working, it’s not worth it.

Quick Fix: Mount Encrypted APFS Drive with AppleScript

automatically unlock an APFS volume with AppleScript

To supplement last week’s post on automatically mounting an external drive to create a clone, here is a quick tip for doing the same thing with an encrypted APFS volume. Ideally, you should be encrypting your backups. If you’re running macOS 10.13 High Sierra, or the impending macOS Mojave, then you will be cloning your system to an APFS volume. If that’s the case, you’ll need to no how to automatically unlock APFS volume with AppleScript.

Automatically unlock APFS volume with AppleScript

There is a little more work involved here, but none of it difficult. The file system might be new, but diskutil is still the command line program doing all the work managing volumes. There is simply a couple more commands involved. This assumes you have already encrypted the drive with Disk Utility.

To mount, or rather unlock an encrypted APFS volume with AppleScript, we need the following information:

  • APFS volume ID
  • Cryptographic user ID
  • The encryption password

The password is the same one you used when you formatted the drive. Here is how to get the other two pieces of the puzzle.

  1. Find the APFS volume ID for your clone drive. You can see this information clearly in Disk Utility. For every volume listed there is a table of information, the device field has what you are looking for. It is some variation of disk1s1. Or if you prefer, with the drive already mounted you can run a terminal command to have the information of all your drives listed, like so:

diskutil apfs list

That command will take a moment, then print a whole lot of information to screen like below. Look for volume you intend to clone your system to and note down the APFS Volume Disk.

Automatically Unlock Apfs Volume With Applescript
You can find the APFS volume ID in a couple of places, if you know where to look
  1. Once you have the volume ID.  In the terminal run the following command (replace ‘apfs_volume_id’ with your disk)

diskutil apfs listcryptousers /dev/apfs_volume_id

You will get something that looks like this:

+-- B4BA200D-B0B7-4AB2-A48C-BDE9FFA7E3BA
	Type: Disk User
	Hint: 1pw

That long alphanumeric code is the Cryptographic user. Copy that code and you have everything you need to make your AppleScript work.

  1. Create the AppleScript to automatically mount your encrypted APFS volume. The script looks like this:
do shell script "diskutil apfs unlockVolume [name_of_your_drive] -user B4BA200D-B0B7-4AB2-A48C-BDE9FFA7E3BA -passphrase [enter your passphrase here]" 

Naturally, you will enter the name of your drive, and replace the user code with the one you copied above. Make sure you remove the square brackets.

  1. Find a way to launch the script when you need it. There are a bunch of options in my previous post. My preferred option is currently Keyboard Maestro, but an Automator Calendar Alarm, or Lingon X work just as well.

Congratulations, you can automatically unlock an APFS volume with AppleScript.


Photo by Patrick Lindenberg on Unsplash

Automatically Mount External Drive to Clone a Mac

Simple Mac Automator Example

I know some people find automation daunting. Fortunately, some of the most effective Mac automations are simple enough to get anybody started. The native MacOS automator app alone can save you from boring and repetitive tasks. Better still, Mac automation can save you from having to remember those tasks. A good example of a simple automation is how to automatically mount an external drive to create a bootable clone for backup.

Backup Strategies for macOS

The past 18 months we’ve had some hardware failures that took me from feeling over-prepared to being relieved I have this all set up. A solid backup and recovery scheme is table stakes for most nerds, but in my experience the same can’t be said of academics. To say nothing of the way most students wing it with their data. I’ve lost count of the horror stories I’m privy to. Undergrads losing devices, or having them pinched. Graduate students having to ask supervisors for a copy of their own thesis, or recompile dissertations from draft fragments. My backup strategy looks like this:

  1. Regular time machine backups to an external drive on my Synology rt2600ac router. Setting up Time Machine to backup wirelessly is an overlooked example of Mac automation
  2. Continuous offsite backup of everything to Backblaze. For US$5 a month, I have almost 6 terabytes of files backed up.
  3. An automated, bootable clone of my entire system updated every night using SuperDuper!

If you have a solid backup strategy, regularly creating bootable clones of your whole system drive is no doubt part of it. If it isn’t, it should be.

Automatically Mounting an External Hard Drive

One of the problems with automating the creation of a bootable clone is the drive must be mounted. That might seem like I’m stating the bleeding obvious, or overlooking an obvious solution, but keeping a clone of your system mounted at all times can create all kinds of problems. Once the drive is indexed, you can have issues with document conflicts, messed up caching, and all manner of application weirdness. It doesn’t take much to launch the wrong version of an app, then you’re in a world of hurt.

The answer, of course, is to automatically mount the drive before backup, and eject it afterwards. But how to do that? Ejecting the drive is the easy part. Any decent backup, cloning app will have this functionality. This includes apps like Chronosync, Carbon Copy Cloner, or if you’re a Setapp user, Backup Pro. My favourite drive cloning software for Mac is Super Duper! for its elegant simplicity. Using Super Duper! to automatically eject the drive looks like this:

Automatically Mount External Drive
Any decent macOS backup utility will have the ability to automatically eject an external drive aftre creating a bootable clone

But, we are putting the cart in front of the horse. The question remains, how to automatically mount the drive. Thankfully, that is also simple. We can use a single command in AppleScript.

One Line AppleScript  to Automatically Mount External Drive

A simple one line AppleScript to make a Mac automatically mount an external drive looks like this:

do shell script "diskutil mount clone"

To make it work you either name your drive ‘clone, or edit the script where it says ’clone’ with the name of the target volume. All that’s left is how to trigger the script. The more you start to peel back the layers on Mac automation, the more you realise how many different options there are. Here are three ways to run the above AppleScript, and automate the mounting of an external drive.

Automatically Mount External Drive with Automator Calendar Alarm


The first option is to use Automator, the native Mac app. Automator can utilise the Mac Calendar app to trigger simple MacOS automations with an alarm. Here's how to setup an Automator Calendar Alarm.

  1. Open Automator from your applications
  2. Choose Calendar Alarm
  3. Search the actions on the left for ‘Run AppleScript’ and drag that action across to the workflow editor on the right — or double click
  4. Clear the window and past our single line of AppleScript into the ‘Run AppleScript’ window. Here is that line of code again:

do shell script "diskutil mount clone"

Simple macOS automation using one line of AppleScript
  1. Click on the little hammer icon to compile the script, then save the workflow and give it a name.
  2. As soon as you save the workflow it will open the calendar app with a new entry. All you need to do is move it, and schedule it like you would any other event.
Automatically Mount External Drive
Automator can trigger an alarm in the native Calendar App to automatically mount an external drive
  1. You’re done, have yourself a Pixie Caramel

There is amore convoluted way to do this from the calendar itself, but the result is the same. I recommend building the workflow yourself, simple as it is. But if you’d rather, you can download a copy here

Automatically Mount External Drive with Keyboard Maestro

I would be happy using the Automator workflow above if I didn’t already use Keyboard Maestro. Setting up Keyboard Maestro to trigger the script is easier still. It’s not the kind of thing I suggest you purchase the app for, but the kind of simple use case it is often overlooked for.


Keyboard Maestro Macro

Automate AppleScript Launch with Lingon X

Another option is to use Lingon X, a powerful automation utility that can launch practically anything. Lingon X is ideal for a job like this. To use Lingon you ned to save the script itself first.

  1. Launch the native Mac Script Editor from Utiities
  2. Paste the AppleScript into the editor do shell script "diskutil mount clone"
  3. Compile with the little hammer
  4. Save the script
  5. Schedule a new job in Lingon X to run the script before your clone is set to run.
simple macOS automation
Lingon X is a powerful utility for creating simple macOS automation

There is also an App Store version for Lingon available.

Choosing an External Hard Drive for Bootable Clone

The last word on this is doubled edged. You should of course try to be savvy about the external hard drives you buy, but this workflow wouldn’t exist if you could be certain you’ll never buy a lemon. I mentioned in my post on replacing the Apple Airport Extreme that Backblaze keep excellent drive statistics. Understandably, it doesn’t include the kind of portable external hard drives you will likely use for this kind of automated clone backup. I feel well covered with my setup, but I know plenty of people who like to rotate the drives and keep one offsite. Either way, I have always found Seagate Expansion drives to be fast, and reliable. Connected to a Hub, and stashed under the desk to avoid more clutter.


Automatically Filing PowerPoint Presentations – Automator, Hazel, AppleScript

This came from a response to a fellow traveller in the Mac Power Users Facebook group. I was about to share the Automator action and Hazel rule that make up this little scheme when it dawned on me that this is a good opportunity to share a fairly straight forward workflow you can easily automate.

This is a fairly common need among students. Most good lecturers will share their presentations with you for their classes. Automating the filing of those slides is both, a good way to save a little time, and a way to ensure a consistent and reliable filing system. I don’t know about you, but my file management can get a little haphazard when done manually.

The situation is simple. Before or after class you are either sent, or given access to download a Powerpoint presentation with the slides for that particular lecture. However, you would rather have a PDF copy – or images as my MPU colleague prefers. There are a few ways you can come at this. If you simply want a PDF copy of the presentation, you can use Hazel to call an AppleScript and convert the file, rename and move it, and you’re done. If on the other hand you want images, you could do the conversion with an Automator workflow and simply add the ‘Render PDF as Images’ action to the end. Thereafter, it is a simple matter for Hazel to move the new file to wherever you want it. I tend to have it placed in my PDF Expert folder in iCloud, so I can markup the presentation on the iPad. Here is what the two versions of Hazel rules, and the Automator workflow look like:


Automatically File Powerpoint Presentations With Hazel
Automator Workflow does most of the work here.  Either Hazel or Automator can rename and move the file


Automatically File Powerpoint Presentations
Automatically File Powerpoint Presentations

If you want to build the Automator workflow yourself — and, there is no better way to learn how to use it — there are a couple of things to look out for. If you have any version of MS Office prior to 2016, you might be able to use the built-in automator action that looks like this:

Convert Powerpoint To Pdf
Previous versions of Microsoft Office included Automator Actions. Whether or not they work will depend on what version of PowerPoint created the presentation

Whether or not that will work for you is going to depend on the version of PowerPoint used to create the presentation. There appears to be some obscure bug with passing Office file names to Automator. As far as I can tell, MS Office no longer supports Automator directly, so you have a choice of hacking what you can from the 2011 actions or using AppleScript. Rather than messing around, trying to debug incompatible actions, AppleScript is your friend here. You can download the script itself here. It is also included in the Automator workflow, which you can download below, along with the Hazel rules. Happy Automating!


Hazel Rules

Automator Workflow

Automating Academic Workflows on a Mac – Part II

Automation Utilities

Picking up where I left off with the first Mac automation post; we covered some of the more well known Automation utilities on macOS in Text Expander, Automator, and Hazel. To be fair, at least one of the areas I cover this time around is likewise pretty well known, but I also want to highlight a couple of unique utilities that qualify as automation tools. These tools have both explicit and implicit utility for study, research, or indeed any academic related workflows. As with all such suggestions, the limit to what you can do with this kind of software will be somewhere between what you can dream up, and how much time you are willing (or able) to sink into them.



Automating Academic Workflows

Popclip is one of those apps that highlights a gap in design reciprocity between iOS and macOS. We have always had the right-click [1] context menu to access functionality in OS X or macOS, but Popclip brings an interpretation of the context menu from iOS back to the Mac. The need to port contextual functionality such as copy and paste to the iPhone and iPad led to the creation of the ubiquitous black speech-bubble that appears from a long press on those devices. Popclip takes that idea, brings it to the Mac, and makes it extensible with customizable actions. I have become so used to using it that if ever I’m on a Mac without it I get a little lost. I use it for text transformations [2], Shortening URLs, dictionary and thesaurus lookups, adding tasks to my task manager, adding links to Pinboard or Instapaper, adding references to Papers, translations, and the list just keeps going. This link will take you to the pre-packaged extensions that are available, but the good news doesn’t end there. Not only will a Github search reveal many more ingenious uses for Popclip, and you can even code your own. To get you started with customization, check out Brett Terpstra’s Popclip Extension Generator

Alfred, Launchbar and others (…but mostly Alfred)

Automating Academic Workflows


A lot of Mac nerds would argue that a Launcher is the purist’s starting point for workflow automation. If you want to keep your hands on the keyboard, then using a launcher is essential. Spotlight has developed well beyond its basic search capabilities in the past few years to the point where, although still relatively basic, it is much more than a mere search engine and application launcher nowadays. What’s more, Spotlight comes baked right into macOS, so a lot of people will find that hitting command (⌘) space will allow you to do a lot more with the keyboard than you realised.

Alfred WorkflowsGoing beyond Spotlight to incorporate automation is where the best third-party launchers excel. As far as which launcher is the best? That honestly depends on who you talk to, but there seems to be a fairly solid consensus that the contenders are LaunchBar, and my personal favourite Alfred.

Both LaunchBar and Alfred are limitlessly extensible; LaunchBar with Actions and Alfred with Workflows. It is difficult to say how one might choose between them [3], but you may find the keystrokes for one, or the other, more intuitive for the way you work. Other than that admittedly abstract and vague selection criteria [4], it is fair to say the user community around Alfred appears much more engaged and accessible. Both the official site and forum, and the unofficial Packal site, are loaded with workflows, advice and friendly automation ninjas willing to help you down a rabbit hole, or back out of one.

Again, I use Alfred for all kinds of things. The screenshot of my workflows is only part of the picture. Searching my Papers library, converting documents with Pandoc[5], searching my Pinboard bookmarks, making currency conversions, task management input, natural-language entry of calendar events, time-stamping notes, Image Optimisation, file management. Alfred is an onion, and in reality I have barely peeled back the first layer. There is a built-in clipboard manager, and text-expander style snippet function. Anything that you can automate via scripting can be triggered via a launcher like Alfred or LaunchBar, which means they capable of all kinds of complicated tasks. As a bonus, they can manage the simple things too, I even lock, logoff and shutdown my Mac with Alfred – and Alfred also has an iOS remote app that allows me to control my Mac from my iPhone or iPad.

These are not the only two apps of this kind, of course. There are die-hards still using the OG launcher, Quicksilver, and given it is open source and free, for some it remains worth a look. Another old favourite of long-time Mac users is Butler, from Many Tricks. There is the lightweight Launcher [6] from Nulana, which is reknown for its advanced calculator and script launcher. Finally, a couple I feel are worth keeping an eye on, the open sauce Zazu App that bills itself as an extensible launcher for ‘hackers, creators and dabblers’, and perhaps the most interesting new app in tis area Lacona, a natural language launcher built on Node.js that already has web automation triggers through IFTTT. [7]


Automating Academic Workflows

Dropzone is another extensible utility that can thread automation actions into your workflow. Another example of an app that is incredibly useful even in its most basic use cases, or can be bent to one’s will with a little ingenuity. The basic premise is very simple, Dropzone is a menu bar app that extends the drag and drop capabilities of your Mac, it houses destinations and automation actions on the ‘drop zone’. You can use it to hold, copy or move files between apps [8], configure it to upload files to cloud services or an FTP server, or social media sites. The real power of the app lies in the customisable actions – I have scripts for renaming files, stripping formatting from text, making animated GIFs, shortening URLs, and so on – but Dropzone also makes for an excellent conduit to other parts of your system. For example, as part of my workflow for posting images to this site I will take a screen shot and drag it to the images folder configured in Dropzone, from there Hazel will invoke an Automator workflow [9] to resize the image, then pass the file to ImageOptim for compression and removal of personal metadata. I could easily automate the whole process, but I don’t want every single screenshot I take sent to the same place, so Dropzone allows me to have a little more control over the file picking.

  1. Or option-click for you die hard, old-school Apple nerds  ↩

  2. Such as capitalisation, Sentence-case for formatting titles, clearing formatting, hyphenating etc  ↩

  3. Some people solve this by using them both, but I’m yet to find something I need LaunchBar for that I can’t do with Alfred  ↩

  4. And the fact the Alfred’s developers have a commendably irreverent name Running with Crayons  ↩

  5. Rather than using the command line  ↩

  6. Yes, an imaginative name that  ↩

  7. Lacona is available with Setapp, a subscription app store I intend to cover soon  ↩

  8. This might sound silly, but for anyone working with fullscreen apps or split-screen it is seriously handy  ↩

  9. The same workflow in the previous article  ↩