Entropy AppleScript Reference


Entropy supports AppleScript. You can programmatically control Entropy to perform tasks such as extracting, creating and inspecting archives.

This guide concisely demonstrates the scripting functionality using a series of examples.

A Python wrapper over the AppleScript layer is also available. The code is available on github.

Extracting Archives

You can extract files from existing archives using the unarchive command.

unarchive: Extract contents of an existing archive.
file : The path of the archive to be extracted.
[destination file] : The destination folder where the files are to be extracted.
[password text] : The archive password.

Example 1: Extract an archive

This is the simplest example of extracting an archive. Since no destination path is provided, Entropy follows the user preferences. That is, if an extraction path is set in the preferences, it will be used. Otherwise, the user will be prompted for an extraction location.

tell application "Entropy"
    unarchive "/Users/Jon/Downloads/Src.zip"
end tell

Example 2: Extract an archive to a specific destination

Here we explicitly provide the destination location for the extracted files.

tell application "Entropy"
    unarchive "/Users/Jon/Downloads/Src.zip" destination "/tmp/"
end tell

Example 3: Extracting encrypted archives

By default, if Entropy encounters an encrypted archive, it prompts the user for a password.
Optionally, you can explicitly provide the password as shown below.

tell application "Entropy"
    unarchive "/Users/Jon/Downloads/Src.zip" password "foobar"
end tell

Creating Archives

To create a new archive, use the archive command.

archive: Create a new archive.
file or list of files : The file(s) to add to the new archive.
[settings archive settings] : Settings for the new archive.

The settings parameter above is an instance of the archive settings class, which is defined as follows.

archive settings: An object for representing archiving options.
password (text) : The password using which the content of the archive will be encrypted.
encryption method (integer) : The encryption method to use.
compression level (integer) : The compression level.
volume size (text) : The maximum size of a single archive volume, with units.

Available Encryption Methods

Format Encryption Type Method Value
Zip AES-256 Data Only 0
7z AES-256 Data Only 0
7z AES-256 Data + Header 1
RAR AES-128 Data Only 0
RAR AES-128 Data + Header 1

Available Compression Levels

Description Compression Level
Normal compression 0
Low compression 1
High compression 2
No compression ( store ) 3

Volume size format

The volume size comprises of two parts — the size ( an integer ) and its unit.
Allowed units are KB, MB and GB ( case insensitive ). If no unit is specified, MB is assumed.
Examples: "4 GB" , "700 MB".

Example 1: Creating a simple archive

Here's how you can create a simple zip archive. The format is automatically detected based on the file extension.
tell application "Entropy"
    archive "/tmp/design.zip" files {"/tmp/icon.psd",
end tell

Example 2: Creating an encrypted archive

This will produce an 7z archive encrypted using the password "foobar".
We set the encryption method to 1, so that the filenames are also encrypted.
tell application "Entropy"
    archive "/tmp/design.7z" files {"/tmp/icon.psd",
             "/tmp/sketches.png"} settings { password:"foobar",
             encryption method:1 }
end tell

Example 3: Creating multi-volume archives

Here's how you can create a set of split archives, each file with a maximum size of 42 MB.
tell application "Entropy"
    archive "/tmp/backup.7z" files "/tmp/latest-backup"
             settings { volume size:"42 mb" }
end tell

Inspecting Archives

To get a list of files within an archive without extracting it, use the inspect command.

inspect: Inspect the contents of an archive.
[details boolean] : Whether details such as file size and modification date should be included.
[password text] : The archive password.
Return value
A list of file paths.

Example: Listing archive contents with details

Each entry includes the full path of the file within the archive, its formatted size and modification data. Folders are marked with an "F".
tell application "Entropy"
    inspect "/tmp/backup.rar" with details
end tell