Downloaded App Mover
26 Jul 2019I recently got a new Mac laptop, my previous one being the best part of a decade old, and I found myself copying new (non-app store) applications from the Downloads folder to the Applications folder far more often than I was comfortable with. To that end I decided to automate the process.
I began by considering using Hazel, but I quickly realised that even though I downloaded an app I didn’t always want to move it in immediately. Often I wanted to mark things off and maybe do some related set-up in terms of grabbing plug-ins, supplementary files, etc.
I decided that a quick shell script would suffice and came up with the following:
#!/bin/zsh
cd ~/Downloads
ls -dtr *.app | tail -n 1 | xargs -I{} mv -f {} /Applications/
Unfortunately this only seemed to work sometimes. On occasion, file permissions would mean that it didn’t move the file, and sometimes I’d get errors like this.
mv: rename SomeApp.app to /Applications/SomeApp.app: Directory not empty
In the end I settled on using an Automator workflow as this seemed to be far more resilient to these sorts of issues. The workflow grabs a list of the applications from the Downloads folder and then uses some AppleScript to pick the most recent application. It then moves that to the Applications folder and displays a notification to indicate that it has been actioned.
I added this into a script step in a simple workflow within Alfred to make it really easy to run whenever I need it.
automator "/Users/stephen/Library/Mobile Documents/com~apple~Automator/Documents/Move Last Downloaded App to Applications Folder.workflow"
It’s purely a convenience thing, but then again, convenience is at the heart of so many automations.