How to use PeaZip programmatically from command line, create CLI scripts, automate batch schedule compression / extraction tasks from GUI.         
DOWNLOAD PEAZIP FREE ARCHIVER         
ONLINE SUPPORT         
SCREENSHOTS         
DONATE




PeaZip command line use, batch scripting syntax examples




PeaZip command line use, batch scripting syntax examples


peazip command line examples
peazip command line syntax

FAQ, HOW TO
ONLINE TUTORIAL
REPORT ISSUES
WHAT IS PEAZIP

CHANGELOG

FILE COMPRESSION BENCHMARKS
REVIEWS



PeaZip acts as a 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

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


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

On
Microsoft Windows Vista and newer 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.

programmatically zip files

Please note those command lines / scripts are targeted directly to backend archiver / compressor utility binaries (7-Zip / p7zip, unace, unrar, Pea, FreeArc...) 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.

PEAZIP'S COMMANDS SYNTAX

  • -add2archive: add to a new archive and open PeaZip GUI to set archive’s type and options;
    •   -add2archive-add as -add2archive, but add to existing archive (if found)
    •   -add2archive-update as previous, but update older files only
  • -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;
  • -add2wipe: securely delete selected file(s);
  • -add2compare: byte to byte compare two files;
  • -ext2browse: open (and browse if applicable) the archive(s) in PeaZip file/archive manager GUI;
  • -ext2browsepath: browse the selected folder (or its path, if a file is selected) in PeaZip;
  • -ext2main: open archive in "Archive extraction" interface, 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.

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:
  • -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
  • -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 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.






PEAZIP WINDOWS INSTALLER SYNTAX EXAMPLES
DOWNLOADS
zip from command line
All PeaZip downloads
PeaZip for Windows 32 bit
PeaZip for Windows 64 bit
PeaZip Portable
PeaZip Linux/BSD
PEA SYNTAX EXAMPLES
SUPPORT
how to zip from command line
Online help
Frequently Asked Questions
More information

zip command examples
DONATE
zip script
Support PeaZip project, or donate to FAO, UNICEF and UNESCO from donation page

© PeaZip srl: 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