Building a Shortcut to Move and Extract ZIP Files (almost automatically)

Continuing on with this dive into the Shortcuts app, let’s explore how to build a Shortcut that will let you move and extract an compressed file such as a ZIP file. As before I want to give a shoutout to the user “JahankeyKong” who requested this on my video about creating nested folders within Shortcuts. So, thanks to them for this idea and checkout that other one if you haven’t.

The goal is when we select a ZIP archive and activate this Shortcut (whether by right-click, keyboard shortcut, etc.) it will first move that ZIP to a specified folder, then open and extract the files inside the ZIP into a folder of the same name. I’ll show you some optional customizations like if you want to manually choose where the files go rather than have it always go to the same location or if you want to delete the original ZIP archive when it’s done. Open up a Shortcuts workspace and give it a name. In my case it’s called “Move and Extract”. We only need five actions to make this work.

First Action: Repeat With Each

The first is the “Repeat with each” action. This may seem like a weird start, and it’s technically not required if you just want to have this run on individual ZIP archives. But should you want to select multiple ZIP files at the same time, then this will Repeat with Each action will let you do that without having to do them one at a time. Adding our repeat action gives us a start point and an end point. Any actions in between will repeat for each unit until specified to stop.

In the first line where it translucently says “Items” we want to right click on this and select “Shortcut Input” from the dropdown menu. Doing this will give you a new action above that lets us select where we get our input and what files to use this on.

Click where it says “Any” and clear all the items in this list with the “Clear” button. Now the only item we want to select from this list is the “Files” options, since we’re only working with compressed files. Once that’s selected, click outside the box. Now to specify where we’re going to get our files. Clicking where it says “Nowhere” and looking in the “Action” sidebar will let us select where our files will come from. Since this is a Mac I’m going to want it to be a Quick Action by checking the “Finder” box. If you’re going to use this extension on iDevices, then you’ll want to check the “Share Sheet” box as well. I’m only going to show this from the right click menu and not set a keyboard shortcut, but you can make one if you want. Now our first action says that the Shortcut will get its files from the “Share Sheet” and/or “Quick Actions” section. With these set we can now build the core of our Shortcut.

The Repeat Action with our settings enabled.

Second Action: Move File

Our Move File action with our settings enabled

The second action we need is the “Move File” action. Dragging that under the start point of our “Repeat” action, it should automatically fill in what we need. But if not, right click the translucent “File” select “Repeat Item” from the dropdown. So it’s going to move each ZIP file selected, but to where? Click where it says “Shortcuts”, click “Replace”, and the file picker box will come up. For this demo, I’m going to set this to be the “Test” folder that’s on my desktop. However you can set this to be wherever you like. You can, however, choose for it to ask you every time in case you have ZIP files that will need to go to different project folders. In that case when the extension is run, it’ll have you select from the file picker box where to put each ZIP file.

Third Action: Create Folder

The Create Folder Action with our settings in place.

For our third action, we’ll need to put in the “Create Folder” action under the Documents type. Like before, it’ll go in our “Repeat” look, just underneath the “Move” action. If we didn’t put this and then extracted the files, the files would all open under that folder where we moved the ZIP files to. That may be fine, but if you’ve got different ZIP files from different projects, having them all mixed together might not be so great. This Create folder actions will let us make a folder for each ZIP file to store the extracted files in. Now click where it says Shortcuts and make sure to set the path to the same as you’re moving the archive. Now where it says “Path”, right click it and click “Repeat Item” from the dropdown. With this the folder will have the same name as the ZIP file we’re opening. Like with the Move action, you can select “Ask Each Time” from the menu instead and have it prompt you to name the folder instead.

Fourth Action: Extract Archive

The Extract Archive action with our settings enabled.

Now for the fourth and main action, it’s the “Extract archive” action. Drag this into our Repeat loop underneath the “Create Folder” action. It should auto-fill with “Created Folder” but we’re going to right click and hit “Select Magic Variable” The workspace will show some new items and things being created at certain steps. We’re going to hit where it says “File” underneath the “Move Repeat Item to Test” or whatever you have your folder named.

Final Action: Save File

The Save File action with our settings in place.

The fifth and final action is to the “Save File” action to have those extracted files saved to the drive. This may seem weird, but the files are extracted but only into your device’s working memory. To save it to our folder, we need to add this action below our “Extract” By default it will autofill “Files” after save, meaning it’s taking the Files extracted from the step before. If it doesn’t, right click and click “Select Magic Variable” and make sure to choose “Files” below the “Extract” option. Next, hit the “Show More” button in the “Save” action, and then uncheck “Ask Where to Save File”. This will cause “…to Shortcuts” to appear, which we’re going to right-click, select “Select Magic Variable”, and then choose “Created Folder” underneath the “Create Folder” action we added earlier.

With that, our core Shortcut is done. As it reads, for every compressed archive we give it either from the iDevice’s Share Sheet or the Quick-Actions section of the right-click menu, it will move it to the Test folder, create a folder with the same name as our archive, and then extract the contents of said compressed archive and save them into that folder.

Options and Quirks

Now I’ve mentioned at a couple points some customizations you can make such as having the Shortcut ask you where you want to move the compressed files and naming the folders created. But what if you don’t want to clutter your drives with all these leftover archives? In this case, you can add an action called “Delete Files” below the “Save File” action in the repeat loop, right click where it says “Files” and select “Repeat Item”. This will delete the archive after the files have been extracted from it.

There is 1 quirk about this action though should you choose to do this. It’s probably to our benefit though. The Shortcut will ask if you want to delete the file every single time it is run. At this time there’s not a way to say “Yes to All” or don’t ask. Again, it’s probably for the best to make sure you don’t accidentally delete something, especially during testing. Just be aware of that.

Demo Shortcut can be found here:

Feel free to comment.

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.