One of the things I get to do as I develop websites on iOS is deal with .zip files. I download plugins for WordPress and need to uncompressed them to upload to a client site. I need to grab a folder of files and compress them for a client so they have a copy of our working files.
While macOS can deal with .zip files out of the box, iOS cannot. Today I’m going to show you the diffent ways I use to deal with .zip files and talk about a few shortcomings I’ve found as I deal with them.
Zipped
First up is zipped only because I found it mentioned on some other site when I first was diving deeper into my iPad and I needed to deal with a zip file.
Zipped makes it easy to grab a bunch of files and then drag and drop them into an archive file. You can also grab an archive drop it onto Zipped and have the file extracted into it’s parts.
This still meant I had to download the archive I wanted and then find it in files only to drag and drop it into zipped and then save it. Luckily an offhand comment by Christopher Lawley and then checking out his iPad screen while paused on YouTube let me know that I could get this more automated with Shortcuts in iOS.
Zip Files in Shortcuts
The first Shortcut I have was stolen directly from Christopher. You’ll find a download link for this in the video description, but I’m going to walk you through the Shortcut so that you can gain a better understanding of what it’s doing.
First we open up the iCloud document picker. Note that we allow Select Multiple. We do this because unfortunately iOS doesn’t let us share a folder into a Shortcut. That means if you want to grab a bunch of files and zip them all up, you’ll need to select multiple items by hand even if they’re already inside a folder.
From there we get the details of our file. Specifically we get the File Extension to see if we have a zip file. Then comes our if
statement. IF
we have a zip file we use Get Variable to get the file extract it and then the Shortcut asks us where to save the file.
One part to note if you’re getting started with Shortcuts is the Get Variable section. We need to get the file variable because if we don’t what’s actually being passed is the file extension from our Get Details of Files
action.
Now we move on to our Otherwise
statement. If
our file did not have the .zip extension we again use Get Variable
to make sure we’re interacting with our file. We take that file and archive it with the Shortcut asking us what we want to name it and then where we want to store it.
Download and Extract a WordPress Plugin from iOS
The second shortcut I use fairly regularly is built to download the contents of a URL and then extract it named properly. I use this to download WordPress plugins for my work as a web developer.
We start this action by long pressing on the “Download” button on our file. Really this could be used for any URL you can touch on the page. Long press it and when the share sheet comes up, select our Download and Unzip Shortcut.
The Shortcut starts by using Get Contents of URL
to download the file we want to unarchive. Next, we get the details of the file, specifically the name of the file. We’ll use that in a bit to name the folder we’re going to save the file into.
Now, we need to use our Get Variable
action to make sure we’re dealing with the downloaded file again, and not the name of the file that came out of our previous action.
On that we use Extract Archive
to unzip our file.
Next we create a folder in our Shortcuts folder in iCloud. We use the result of Get Details of Files
as the folder name so that our folder is named sensibly.
Again, we go back and use Get Variable
to get the main file that we’re working with. If you’re creating this yourself, make sure that you use the file
that was coming out of the Extract Archive
action.
Then we use Save File
to save the file we’ve downloaded. How long this part takes depends on how big a file you’re dealing with. A huge archive will take a while a smaller one will take less time.
Now you’ve got your folder of files unzipped waiting for you to do whatever you wanted to with them.