batch scripting with peazip         
DOWNLOAD PEAZIP         
ONLINE SUPPORT         
SCREENSHOTS         
BENCHMARKS         
DONATE




how to use peazip from command line






PeaZip command line use, batch scripting syntax examples


peazip command line examples
peazip command line syntax

FAQ, HOW TO
ONLINE TUTORIAL
ISSUE TRACKER, CVE

CHANGE LOG

TOS, PRIVACY

WHAT IS PEAZIP

REVIEWS



PeaZip scripting engine


PeaZip acts as scripting engine frontend for many Open Source archiving executables (7z / p7zip, FreeArc, unace, PAQ, LPAQ, ZPAQ, UPX...).
Due its frontend architecture most tasks possible to be accomplished with PeaZip GUI can be converted and exported to command line, and saved as script (batch file or shell script), using Save task definition button in Console tab (in archiving/conversion and in extraction interfaces), or console button in task's window.

rar command line examples



Export GUI tasks as CLI scripts


From the Console tab the task can be modified and tested, before being saved for future programmatical use.

Exporting GUI-defined jobs as script bridges the gap between GUI and command-line software worlds, taking the best of both: users can benefit of those saved sample scripts (main menu Tools > Saved task definition scripts points to the default PeaZip's script directory) that can be used programmatically as is, or as examples or building blocks to speed up further scripting, or for learning purpose about the underlying executables (in example build examples for backend p7zip / 7-Zip command line syntax), or for fine-tuning the task beyond the GUI's capabilities.

Exported tasks are displayed as UTF8 text and can be freely saved, in example (but not only) as
Bash shell on Unix systems, or .bat or .ps1 PowerShell script on Microsoft Windows platform.

7Z TAR ZIP syntax console shell examples



Export file encryption tasks as CLI scripts


If encryption password is needed to complete the task (batch create an encrypted archive of files, or batch extract a password protected archive), it needs to be written in the command line or script, otherwise the password will be asked interactively and the task will not run unattended - a supervisor will need to enter the password when required by the running job.
Please note very carefully that if the password is saved as plain text to a script file, it has to be protected with maximum care.

To avoid the password being saved to the .bat script,
  • for archive extraction / backup reatore tasks, simply omit to enter the password, it will be asked interactively when running the script
  • for archive creation / backup creation tasks, you can delete the password from the script prompted in Console tab, before saving it. The password switch appear in as "-pthisisthepassword", removing the password part and letting the switch as "-p" the password will be asked interactively when running the script


Export scripts as scheduled tasks


On
Microsoft Windows Vista and newer Windows systems, Schedule tab (in archiving/conversion and extraction interfaces) is intended as a quick way to schedule (in builtin Windows system's Task scheduler) a scripted task defined in Console tab, in example to automate backup or restore job launching the saved script file(s) at user-defined times, or under specific circumstances / events.

Use
PeaZip scripting engine to learn the syntax of backend binaris (7z, p7zip, unrar, zpaq, brotli, zstandard...)

programmatically zip files

Please note those command lines / scripts are targeted directly to backend archiver / compressor utility binaries (7-Zip / p7zip, unace, unrar, Pea, Brotli, Zstandard, Zpaq...) so are useful for creating examples to understand and experiment the syntax of those tools.

command line zip examples

PeaZip provides its own command line syntax, in order to simplify the task of script creation, offering an unified set of commands using underlying functions without having to explicitly use the syntax of backend binaries: this is the subject of following section.

Please note you need to use absolute paths (full qualified paths, also supported in UNC path form) when writing command lines or scripts for PeaZip or for backend utilities binaries; otherwise, you will need to add PeaZip's program's directory to system's paths so the OS will be able to find the proper executables to run. For listing input and output files / directories it is always recommended to use absolute paths.
Saving, or copy / pasting, task definition from console tab as shown in previous chapter can help speed up finding and writing executables, input, and output paths in absolute form. Correctness of paths saved in scripts will need to be verified, if scripts are used on a different machine.

One of the scopes of PeaZip project is offering a simple and homogeneous frontend command line interface to mask the complexity and the differences in CLI syntax of back-end executables, "converting" commands into simpler PeaZip's syntax mapping instructions for most common compression / extraction tasks.
Quick access to most used PeaZip’s functions is provided passing as first parameter a constant string value identifying the function; those methods can be used invoking PeaZip from scripts or also creating a link to PeaZip executable with the desired first parameter (e.g. Windfows SendTo menu).
THis also allow integration of PeaZip with context menus in Linux (.desktop files) and macOS (Automator scripts); special switches to be used in Windows registry are also available, allowing to integrate PeaZip in Windows right-click menu.

PeaZip command syntax

  • -add2archive: add to a new archive and open PeaZip GUI to set archive’s type and options;
  • -add27z: add to a new .7z archive;
  • -add27zmail: add to a new .7z archive and attach it to a mail, requires compatible mail client like in exampe Outlook and Outlook Express
  • -add2separate7z: add each input to a separate new .7z archive;
  • -add2sfx7z: add to a new self extracting 7z archive (.exe);
  • -add2sfx7zmail: add to a new self extracting archive and attach it to a mail, requires compatible mail client like in example Outlook and Outlook Express
  • -add2zip: add to a new .zip archive;
  • -add2zipmail: add to a new .zip archive and attach it to a mail, requires compatible mail client like in example Outlook and Outlook Express
  • -add2separatezip: add each input to a separate new .zip archive;
  • -add2pea: add to a new .pea archive;
  • -add2crypt: add to a new encrypted .pea archive;
  • -add2split: raw split a single input file;
  • -add2brotli -add2bzip2 -add2gzip -add2tar -add2wim -add2xz -add2zstd -add2zpaq
Directly add files and folders to a new archive in the specified format, with latest options used for that format (-add2zpaq switch sets last used *PAQ format); TAR is automatically applied when folders and/or multiple files are sent to formats which supports single file compression (Brotli, BZip2, Gzip, XZ, Zstd).
If no input file or folder is provided after the switch, the archive creation screen remains open for input.
Same switches in -add2multi* form can be used for integration in Windows registry.
  • -add2preset N uses Nth preset settings; presets are numbered from 0 to 15, are fully customizable, and can be found in (peazip)/res/share/presets directory
  • -add2custom (full qualified name of the custom compression setting) uses the custom compression setting specified after the switch
-add2preset and -add2custom switches can be used in scripts (.reg, desktop files, .workflow service menus) employed to integrate PeaZip with Linux, Mac, and Windows systems, in order i.e. to make a personal, custom compression setting readily available from system's context menu
If "Immediate execution" option is enabled (dropdown on the right of Add button in PeaZip GUI), -add2preset and -add2custom will start compression immediately without requiring confirmation, otherwise it will be possible to modify the task further before confirming with OK button.
  • -setcomment commentstring archive1..n set the text in commentstring as comment for specified archives
  • -setcommentf commentfile archive1..n set the text loaded from file commenfile as comment for specified archives
  • -removecomment archive1..n remove comment from specified archives
  • -ext2main: open archive in "Archive extraction" interface to extract input archive(s), allowing to specify i/o options, password and keyfile (interactively);
  • -ext2here is a simplified “blanket” extraction command for all backends accepting as parameter the input archive(s) to be extracted as in "Extract here" action, using as output path the directory containing the archive (or the first archive of the list in case of multiple input): "extract to new folder" and "smart new folder" directives are both set to off during the execution of this function, without modifying program's configuration.
  • -ext2folder (alias-ext2smart) works as previous switch but setting both "extract to new folder" and "smart new folder" directives on. In this way the archive is extracted to a fresh new folder with unique name (named after the archive), but only if 1) the archive's root contains more than a single file or a single directory, and 2) in case a file or directory with same name exists in destination path.
  • -ext2newfolder: works as previous switches but setting "extract to new folder" on and "smart new folder" off, in this case the archive's content is always extracted to a fresh new folder with unique name, named after the archive.
    • -ext2to (and -ext2tofolder, -ext2newfolder...) variants extract archive(s) interactively asking for output directory;
    • -ext2simple (and -ext2simplefolder, -ex2simplenewfolder) variants allows to specify output path as first parameter;
    • all those switches runs multiple extraction tasks in a single GUI instance (which shows progress bar for current task and another progress bar for global progress), allowing i.e. to minimize the entire batch of tasks. If this behavior is not wanted, switches with "_" suffix, i.e. -ext2here_, runs each extraction process as a separate GUI instance.
  • -ext2list: list archive(s) content, to quickly look what is in the archive;
  • -ext2test: test archive(s) content;
  • -ext2openpwtest requires password as paramstr(2) (always delimited) and archive’s full name as paramstr(3): try to list the archive and terminate with exit code 0 if archive is not encrypted, 1 if it is encrypted, 2 if it is non readable (corrupted or with encrypted file list), -1 if archive is not found.
  • -ext2commandprompt: open the command prompt in the selected folder (or in its path, if a file is selected)
  • -peaziplanguage followed by name of the langiage file e.g. it.txt changes language of the GUI and, on Windows installable version, launches the .reg file containing translated strings for the system's context menu entries (which requires UAC)
  • -peazipreset: reset PeaZip configuration, as Options > Reset button; can resolve unexpected problems with configuration, restarting the application with factory settings
-add2archive, -ext2main and -ext2browse open the PeaZip GUI, to allow further user’s interaction

Direct batch archiving functions as
-add2pea, -add2crypt, -add27z, -add27zmail, -add2separate7z, -add2sfx7z, -add2sfx7zmail, -add2zip, -add2zipmail, -add2separatezip

and direct batch extraction functions as
-ext2here, -ext2folder, -ext2newfolder and variants (e.g. -ext2to, ext2tofolder, -ext2simple, -ext2simplefolder...)

can delete (asking for confirmation) input files as atomic operation if this policy is set in PeaZip - delete after archiving and delete after extraction checkboxes in archiving and extraction screens respectively.

As it could not be handy to have an interactive request prompt in a batch script, an alternative version for those actions not applying deletion policy after archiving/extraction is available appending “i” letter to the command: -add2peai, -add2crypti, -add27zi, -add27zmaili, -add2separate7zi, -add2sfx7zi, -add2sfx7zmaili, -add2zipi, -add2zipmaili, -add2separatezipi, and -ext2herei, -ext2folderi, -ext2toi, ext2tofolderi, -ext2simplei, -ext2simplefolderi.
Using those version of the commands, PeaZip’s "delete after archiving" and "delete after extraction" directives are explicitly ignored.

Syntax of registry entries for integration with Windows context menu


On MS Windows platforms PeaZip can also send multiple input to a single instance using semaphores and temporary files (temp files are deleted automatically but in case of any kind of problem there is a reset switch in Options > Settings first tab to remove any possible leftover), this allows the command verb to be used in static registry entries (in example in Windows systems context menu) to send multiple input to a single instance:
This method also works for Windows 11 mini context menu, see .reg scripts examples in (peazip)\res\share\batch\Windows 11 mini context menu folder, setting custom MUIVerb entries for whitelisted IDs.
  • -add2multi works like -add2archive
  • -add2multi7z works like -add27z, but stays in the archiving interface until the user click "Ok" button; it can be modified in -add2multi7zfastest, *normal, or *ultra to directly set the compression to fastest, normal or ultra levels presets (the compression method used is the one defined by the user); *mail send 7z archive by mail; *encrypt create encrypted 7z archive
  • -add2multizip works like -add2zip, but stays in the archiving interface until the user click "Ok" button; likewise the previous switch it can be modified to *fastest, *normal, or *ultra compression level; *mail send zip archive by mail
  • -add2multibrotli -add2multibzip2 -add2multigzip -add2multitar -add2multiwim -add2multixz -add2multizstd -add2multizpaq directly add files and folders to archive of specified format wiuth default compression options
  • -add2multisfx works like -add2sfx7z, but stays in the archiving interface until the user click "Ok" button
  • -ext2multi works like - ext2main
While the program's instance accepting files is open, it is possible to continue adding input from the same directory selecting objects and using context menu’s entry, as an alternative to dragging the object to the application window that might be less handy if the workspace is crowded.

Compression and extraction syntax examples

  • peazip -add2zip file1 file2 directory3 will add specified objects (file1 and file2, and all content of directory3) to a .zip archive; using -add27z instead of -add2zip will perform the same task but will result in a .7z archive (-add2pea will result in a .pea archive, -add2sfx7z will result in an self extracting executable and so on).
  • peazip -ext2here archive1 will extract archive1 in its path; using -ext2folder archive1 will be extracted to a new folder named "archive1" in the same path of archive1 file (smart new folder option enabled)
  • peazip -ext2simple archive1 somedirectory extract archive1 in "somedirectory" path

PeaZip Windows installer syntax examples


/SILENT performs an unattended installation, not requiring user's feedback and assuming default values for all installation parameters

/VERYSILENT performsa an unattended installation not showing the installer's UI

/IT (example) to set application's language - also apply translation to system's context menu entries for PeaZip
Language, if needed, must be declared as last parameter, with or without "/" prefix.
Supported languages are AR, BG, BY-CR, BY-LT, CHS, CHT, CZ, DEFAULT, DE-UM, EN, EN-GB, ES-ES, ES-LA, EU, FI, FR, GL, GR, HE-PROTOTYPE, HU, ID, IT, JA, KO, LV, NL, NO, PL, PT-BR, PT-PT, RO, RU, SI, SK, SL, SV, TJ, TR, UK, UZ, VN.
Generally language file isa named using the two letters international abbreviation, with exceptions: to identify the exact names of supported languages you can check the filename of language files in PeaZip\res\lang\ directory.

PEA syntax examples


Syntax for pea backend is documented in PEA archiving utility page and on PEA file format specifications and implementation notes (pdf)

More information: batch file.bat file for Microsoft Windows and shell scriptunix shell commands Wikipedia definitions


Synopsis: How to use PeaZip from command line in terminal and scripts. How to export tasks as scripts from the GUI. How to save ad edit task definition as CLI scripts. How to programmatically use PeaZip from shell to compress / extract files. How to automate batch compression / extraxtion tasks. Learn PeaZip command line syntax by examples. Learn 7z, rar, tar, zip backends command line syntax by examples.

Topics: PeaZip command line turorial, Pea syntax examples, scripting usage, batch extract archives, compress files from console

PeaZip > FAQ > PeaZip command line use, batch scripting syntax examples


use peazip from command lineTIPS & TRICKS

Add PeaZip to context menu

Change PeaZip language

Dark mode for PeaZip

Drag and drop from / to PeaZip

How to create RAR files?

PeaZip command line scripting syntax

Reduce Virtual Machines disk images space occupation

How to unlock unreadable files?





PEAZIP WINDOWS INSTALLER SYNTAX EXAMPLES
DOWNLOADS
zip from command line
All PeaZip downloads
PeaZip for Linux
PeaZip for macOS
PeaZip for Windows
PeaZip sources
PEA SYNTAX EXAMPLES
SUPPORT
how to zip from command line
Online help
Frequently Asked Questions

peazip file compression software
ABOUT
peazip free archiver utility
PeaZip project: TOS, Privacy
Releases Feed Create command line scripts and scheduled tasks
PeaZip Wiki How to use PeaZip from command line
Developer email PEAZIP'S COMMANDS SYNTAX by eamples
Search knowledge-base
zip COMPRESSION and EXTRACTION SYNTAX EXAMPLES