How Do I Unarchive All Files in Selected Folders?

Hi, I am new to Keyboard Maestro and since a week I tried to create a workflow for automatically unarchiving files but without success ! So I decided to ask for your help :wink:

Here’s the situation : in my work I often receive archived files (mainly .rar & .zip but also sometimes a few .dms files), those files are all stored in different folders and each time I have to go through all those folders and unarchive all that the file by file, what makes me lose a lot of my precious time!
So, I tried by myself to establish a workflow in K.M. so it all can be done automatically but I am not really into it as it never worked like it should have been the case!
You’re now my last resort :wink:

This is what I would have like the workflow to do :

  1. ask the user to select manually all the folders that the workflow will have to deal with
  2. look in all those folders, and their sub-folders to see if they’re containing archives
  3. if this is not the case to go directly to the next folder to perform the same research
  4. if this is the case to undertake the unarchiving of all the presented files and to move the intial files (that are now unarchived) to the trash (but without deleting them)
  5. after each unarchiving to perform a control of the left space available on the hard disk and, if the available space is higher than 70GB to continue with the unarchiving task, if it less then 70GB to stop immediately the procedure and ask the user if he wants to empty the trash (menu with two choices)
  6. if the user chose No -> leave the workflow
  7. if the user chose Yes -> empty the trash and display the total of the now available total diskpace in GB
  8. propose to the user of to continue the procedure or to quit the workflow and act accordingly

Do you think that it is possible to establish such a workflow in Keyboard Maestro?
If yes do you have some suggestions how to do it?

Many thanks in advance 

I am not yet sure if I will write the solution. However I read your post. I have a few questions. My questions may help me or others to understand what needs to be done.

  1. I think you made a mistake in step 7. Shouldn't it say "If the user chose yes"? I'm confused.
  2. Are you using any software to de-archive those archives, or are you simply using macOS? If yes, what software?
  3. When you say 70GO and 70Go do you mean 70GB?
  4. Since the user has to be sitting there the whole time, is it okay if step 1 asks for only a single folder instead of multiple folders (which implies that step 1 gets repeated later on if the user wants to process more folders.)

@Paul_Kersey, I hope you don't mind that I have revised your topic title to better reflect the question you have asked.

FROM:
Is it possible to create such a macro? - Help needed

TO:
How Do I Unarchive All Files in Selected Folders?

This will greatly help you attract more experienced users to help solve your problem, and will help future readers find your question, and the solution.

Hi Sleepy,
Thanks for your answer and remarks. You're right I made a mistake at the step 7 and I edited my post in this sense, as I did it also for the GB in place of GO (we rather use GO in place of GB in my country, but it's the same).
For the de-archiving I am using usually "BetterZip" or "The Unarchiver".
For what concerns the step 1 it's OK for me that the workflow asks for only one folder as long as, thereafter, it automatically looks in all the subfolders of this folder and performs automatically all the needed de-archiving of all archived files. In fact on the hardisk the situation is usually the following one : Harddisk(root)/FolderA/Folder1->Folder100 and the archived files are all situated in the numbered folders (1 to 100 in this exemple), so if at step 1 the workflow just ask for one folder and that the user gives as answer the FolderA i't's ok as long as it looks thereafter in all the subfolders that are in this exemple folder1 to folder100 and the perform then rest of the workflow on them.

I hope I answered your question with this,
Anyway thanks for your interest and possible help. :slight_smile:

Paul

No problem, thank you, you're right it's a better title :slight_smile:

Since I don't have those software items I can't write code that will invoke those programs for you. Manipulating software requires having the software to be able to design and test any KM code. Do those programs come with a command line (for a macOS shell) version? If you showed me the syntax for a command line version I could probably write it. In any case I will attach below a DRAFT KM program, totally untested, which I think is roughly what the code would look like. I used a hypothetical command line command for your extraction software, since I don't know whether your program even has one. I also used a comment in place of the delete trash command, because the delete trash command (which is a recursive delete command) is very simple but one little typo in that command could erase your whole disk so for now I'm leaving that as a comment for everyone's safety.

There are several interesting techniques used in this draft piece of code and you may want to ask me about them if you don't understand them. basically it prompts for a folder, then it validates if the folder is less than 10% free (I used 10% free instead of 70 GB, just for this draft code), then it optionally empties the trash, then it recursively extracts all the ZIP files from that folder location. Roughly that's what you wanted. The program weds whenever you click Cancel on the directory, or whenever you click Cancel on the Trash prompt.

Does my program have any bugs? Possibly - it's not meant to be a debugged program, it's only meant to give you ideas for now.

The below macro does Steps 1-4. This should get you started, and you can add the remaining steps. Be sure to carefully read the ReleaseNotes to understand how it works, and some changes you may need to make.

MACRO: UnArchive (UnCompress) All Files in Selected Folders [Example]

Please let us know if this works for you.

Many thanks Speedy I'll give it a try as soon as possible :slight_smile:

For what relates to the two softwares that I use for decompressing : BetterZip & The Unarchiver
and their integration/interaction with Keyboard Maestro I found those webpages :

I had a look at it and at the end of the first webpage there's something that look like a script for K.M. but my beginner's level in Keyboard Maestro does not permit me to understand it.
On the second Webpage you'll find links for downloading command lines for The Unarchiver, but also here it is too much for my level of knowledge!

And once again, many, many thanks for your help,

Paul

Many thanks for your help Indy,
I'll try this macro and test it directly this week-end, for this I'll of course use copies of the concerned files as I am a real newbie in Keyboard Maestro :wink:

I promess to let you know how it worked for me.

A great thank you,

Paul

Good. If you have problems, let me know.