UnArchive (UnCompress) All Files in Selected Folders [Example] Macro (v9.0.2)

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

~~~ VER: 1.0    2019-10-01 ~~~
Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

DOWNLOAD Macro File:

UnArchive (UnCompress) All Files in Selected Folders [Example].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.

This Macro was written in response to this request:
How Do I Unarchive All Files in Selected Folders?


Example Input

image

Example Output


ReleaseNotes

Author.@JMichaelTX

PURPOSE:

  • UnArchive (Uncompress) All Compressed Files in Selected Folders

HOW TO USE

  1. First, make sure you have followed instructions in the Macro Setup below.
  2. Select the FOLDERS in the Finder that Contain Files to UnArchive
    • Use CMD-Click to Select Non-Adjacent Folders
  3. Trigger this macro.

MACRO SETUP

  • Carefully review the Release Notes and the Macro Actions
    • Make sure you understand what the Macro will do.
    • You are responsible for running the Macro, not me. ??
      .
      Make These Changes to this Macro
  1. Assign a Trigger to this macro.
  2. Move this macro to a Macro Group that is only Active when you need this Macro.
  3. ENABLE this Macro, and the Macro Group it is in.
    .
  • REVIEW/CHANGE THE FOLLOWING MACRO ACTIONS:
    (all shown in the magenta color)
    • IF: Process ONLY Files That Match Archive Type
      • Change the "matches" field to include File Kinds that you want to process
    • SCRIPT: UnArchive File Using "The UnArchiver" Tool

REQUIRES:

  1. KM 9.0+ (may work in KM 8.2+ in some cases)
  2. macOS 10.11.6 (El Capitan)+

TAGS: @UnArchive @UnCompress @Finder @Zip

USER SETTINGS:

  • Any Action in magenta color is designed to be changed by end-user

ACTION COLOR CODES

  • To facilitate the reading, customizing, and maintenance of this macro,
    key Actions are colored as follows:
  • GREEN -- Key Comments designed to highlight main sections of macro
  • MAGENTA -- Actions designed to be customized by user
  • YELLOW -- Primary Actions (usually the main purpose of the macro)
  • ORANGE -- Actions that permanently destroy Variables or Clipboards,
    OR IF/THEN and PAUSE Actions

USE AT YOUR OWN RISK

  • While I have given this a modest amount of testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
  • If you have any doubts or questions:

I forgot to include this information in the above macro.
The macro uses this command-line uncompress tool called The Unarchiver . You can download it from here. It claims to support than 20 different archive formats.

I use it in this Action:

image

Note that I have set a standard KM Variable to the unix path of all of my command-line programs:
ENV_PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin

You may need to change this KM Variable, or add the explicit path if unar is stored in a different location on your Mac.

unar Command-line Usage

unar -h
unar v1.10.1 (May 19 2016), a tool for extracting the contents of archive files.
Usage: unar [options] archive [files ...]

Available options:

-output-directory (-o)
The directory to write the contents of the archive to. Defaults to the current directory. If set to a single dash (-), no files will be created, and all data will be output to stdout.

-force-overwrite (-f)
Always overwrite files when a file to be unpacked already exists on disk. By default, the program asks the user if possible, otherwise skips the file.

-force-rename (-r)
Always rename files when a file to be unpacked already exists on disk.

-force-skip (-s)
Always skip files when a file to be unpacked already exists on disk.

-force-directory (-d)
Always create a containing directory for the contents of the unpacked archive. By default, a directory is created if there is more than one top-level file or folder.

-no-directory (-D)
Never create a containing directory for the contents of the unpacked archive.

-password (-p)
The password to use for decrypting protected archives.

-encoding (-e)
The encoding to use for filenames in the archive, when it is not known. If not specified, the program attempts to auto-detect the encoding used. Use "help" or "list" as the argument to give a listing of all supported encodings.

-password-encoding (-E)
The encoding to use for the password for the archive, when it is not known. If not specified, then either the encoding given by the -encoding option or the auto-detected encoding is used.

-indexes (-i)
Instead of specifying the files to unpack as filenames or wildcard patterns, specify them as indexes, as output by lsar.

-no-recursion (-nr)
Do not attempt to extract archives contained in other archives. For instance, when unpacking a .tar.gz file, only unpack the .gz file and not its contents.

-copy-time (-t)
Copy the file modification time from the archive file to the containing directory, if one is created.

-no-quarantine (-nq)
Do not copy Finder quarantine metadata from the archive to the extracted files.

-forks (-k) <fork|visible|hidden|skip>
How to handle Mac OS resource forks. "fork" creates regular resource forks, "visible" creates AppleDouble files with the extension ".rsrc", "hidden" creates AppleDouble files with the prefix "._", and "skip" discards all resource forks. Defaults to "fork".

-quiet (-q)
Run in quiet mode.

-version (-v)
Print version and exit.

-help (-h)
Display this information.