How to unzip remote archives in Transmit without using the awkward menus
Table of Contents
I use Transmit to SFTP to my servers, & I often have to unzip archives on those servers. The way Transmit makes you do it is awkward, cumbersome, slow, & annoying:
- Select the remote ZIP file.
- Click on File > Send SSH Command…. A sheet opens at the top of the Transmit window.
- On that sheet, click on the action menu (the little sprocket). A menu appears.
- Click on Unzip Selection. The original SSH Command sheet disappears & another sheet opens, displaying the output from the
unzip
command. - Press OK to close the sheet with the output from
unzip
. - Repeat the entire process with the next zip file.
This sucks.
There’s no key command for this action. You can’t use the Keyboard System Pref to set one, because it requires multiple steps.
There’s nothing exposed in Automator for this, so you can’t use that tool (which also rules out simple AppleScripting, of course).
You can’t even unzip more than one file at a time. Brilliantly (this is sarcasm), if you select more than one remote ZIP file & perform the steps I listed, when you get to step 4, Unzip Selection is grayed out so that your only option is Zip Selection. Good thinking there, guys.
What’s really pathetic is that the free & open source Cyberduck has provided easy, sensible unzipping of remote archives for years. The problem is, I like Transmit for everything else. It’s faster, it’s got a better UI, & it just does more. But when it comes to remote unzipping, Cyberduck has Transmit beat by a mile.
An AppleScript to solve the problem
So today I figured out how to automate the process in Transmit. I said above you can’t use simple AppleScripting, but you can still use more difficult AppleScript commands & references to get the job done.
Open AppleScript Editor & paste the following in:
Save the script as Transmit > Unzip Remote Archive.scpt
in ~/Library/Scripts/
. To use it, select the remote ZIP file in Transmit, click on the Scripts menulet on the Menu Bar, & select our script. A moment later you should see the output of your unzip
command. Review it for errors1, press OK to close it, & your file is now unzipped. If you have another file to unarchive, select it & choose the script again2.
Details about the script
I’m not an AppleScripter, but I can piece things together. Here are some notes on a few of the lines in the script.
click menu item "Send SSH Command…" of menu "File" of menu bar 1
To figure out how to select a menu item, I used Benjamin S. Waldie’s “User Interface Scripting”. The Menu Bar is always menu bar 1
; once you know that, it’s easy to select specific menu items.
click menu button 1 of sheet 1 of window 1
This was the tricky bit. Well, one of them. To figure out the UI hierarchy (the menu button inside the sheet inside the window), I used Apple’s Accessibility Inspector, which I first found out about in Dr. Drang’s article of the same name.
keystroke "U"
This was a pain. I tried to use the Accessibility Inspector to identify the menu item, but I couldn’t. I can’t tell if it’s my own incompetence (likely) or a problem with the Accessibility Inspector or something with Transmit or just an issue with the fake-kinda menus that action menus create. Either way, I gave up trying to identify the Unzip Selection menu the quote-unquote correct way & finally just went with the easy method: type U, which selects Unzip Selection. With only two choices (“Unzip” & “Zip”), this works just fine.
key code 36
How to press Enter/Return in AppleScript? What I thought would work did not. A bit of Googling, & I found out how to do it via a specific key code.
Keyboard Maestro
God, I love Keyboard Maestro. It is truly the bee’s knees. If you use KM, you can use my script like this:
Note that the first line of the AppleScript above (tell application "System Events" to set frontmost of process "Transmit" to true
) is gone. Instead, I use KM’s built-in ability to bring apps to the forefront. I didn’t have to do that, but I like using the capabilities in apps if I can. I set the key command to Ctrl-Shift-U, with the “U” short for “unzip”.
I really wish Panic, the makers of Transmit, would make it easier to unzip remote archives. I filed a bug slash feature request well over a year ago, & I got a reply from someone at Panic telling me that they would think about it. Since then, nothin’. Until Panic fixes this annoyance, my little AppleScript for Transmit will have to suffice.
-
Yes, that modal sheet is annoying, but it’s important to review too. If you have an error unzipping an archive, you want to know immediately. So don’t just click OK to close it—scroll to the bottom & make sure there are no errors. ↩
-
I’d love to be able to just select multiple ZIP files & have the AppleScript iterate over them, but that sheet appears each time with the output of the
unzip
command, which stops things in their tracks. That said, that output is a good thing: like I said, you want to know if there’s an error. But it does prevent you from working on multiple files at the same time. ↩