Patool is a portable command line archive file manager

Related tags

CLI Tools patool
Overview

Patool

Patool is an archive file manager.

Various archive formats can be created, extracted, tested, listed, searched, repacked and compared with patool. The advantage of patool is its simplicity in handling archive files without having to remember a myriad of programs and options.

The archive format is determined by the file(1) program and as a fallback by the archive file extension.

patool supports 7z (.7z, .cb7), ACE (.ace, .cba), ADF (.adf), ALZIP (.alz), APE (.ape), AR (.a), ARC (.arc), ARJ (.arj), BZIP2 (.bz2), CAB (.cab), COMPRESS (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms), FLAC (.flac), GZIP (.gz), ISO (.iso), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar, .cbr), RZIP (.rz), SHN (.shn), TAR (.tar, .cbt), XZ (.xz), ZIP (.zip, .jar, .cbz) and ZOO (.zoo) archive formats. It relies on helper applications to handle those archive formats (for example bzip2 for BZIP2 archives).

The archive formats TAR, ZIP, BZIP2 and GZIP are supported natively and do not require helper applications to be installed.

Examples

# Extract several archives with different formats
patool extract archive.zip otherarchive.rar

# Extract archive with password
patool extract --password somepassword archive.rar

# Test archive integrity
patool test --verbose dist.tar.gz

# List files stored in an archive
patool list package.deb

# Create a new archive
patool create --verbose /path/to/myfiles.zip file1.txt dir/

# Create a new archive with password
patool create --verbose --password somepassword /path/to/myfiles.zip file1.txt dir/

# Show differences between two archives
patool diff release1.0.tar.gz release2.0.zip

# Search for text inside archives
patool search "def urlopen" python-3.3.tar.gz

# Repackage an archive in a different format
patool repack linux-2.6.33.tar.gz linux-2.6.33.tar.bz2

Website

See http://wummel.github.io/patool/ for more info and downloads.

API

You can use patool functions from other Python applications. Log output will be on sys.stdout and sys.stderr. On errors, PatoolError will be raised. Note that extra options such as password input or customization for specific archive programs are not supported.

import patoolib
patoolib.extract_archive("archive.zip", outdir="/tmp")
patoolib.test_archive("dist.tar.gz", verbosity=1)
patoolib.list_archive("package.deb")
patoolib.create_archive("/path/to/myfiles.zip", ("file1.txt", "dir/"))
patoolib.diff_archives("release1.0.tar.gz", "release2.0.zip")
patoolib.search_archive("def urlopen", "python3.3.tar.gz")
patoolib.repack_archive("linux-2.6.33.tar.gz", "linux-2.6.33.tar.bz2")

Test suite status

Patool has extensive unit tests to ensure the code quality. Travis CI is used for continuous build and test integration.

Build Status

Comments
  • Fix flac CI error

    Fix flac CI error

    Fixes flac-related CI failures as discussed in #83

    I've also noticed that, while it would be useful to use a newer ubuntu distribution, the newest that also includes the zoo package is xenial (see repology, and I think that's being used at the moment as the default on travis), and since xenial uses flac 1.3.1, the version with the bug, the only option that handles both is to downgrade to trusty with flac 1.3.0.

    It could also be possible to get zoo installed on a newer distribution, either manually or using a ppa, but that would be more work. I suppose support for zoo could also be deprecated, but that's probably not ideal either.

    opened by benjaminwinger 8
  • Need an overwrite mode

    Need an overwrite mode

    When extract an rar archive it asks:

    a_file_name.txt already exists. Overwrite it ? [Y]es, [N]o, [A]ll, n[E]ver, [R]ename, [Q]uit

    Sometime it's need to work without interactive mode with ability to turn on/off an overwrite mode.

    opened by xmm 8
  • Means of programmatically overwriting pre-existing files?

    Means of programmatically overwriting pre-existing files?

    Hi,

    I'm using patool to programmatically unarchive a variety of archivables by calling it via subprocess in python. Here's my basic code:

    def unarchive(file_path, file_dir):
      """
      Use patool for universal extraction.
      """
      args = ['patool', 'extract', file_path, '--outdir', file_dir]
      p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      (out, err) = p.communicate()
      return out, err
    

    However, in some cases if there are duplicate files in an archive, patool will ask for user input as how to proceed:

    EO-926055986-N81-2014/CAT. No. EO-926055986-N81-2014       14-PL-0179.xlsx already exists. Overwrite it ?
    [Y]es, [N]o, [A]ll, n[E]ver, [R]ename, [Q]uit A
    

    Unfortunately, this means that the subprocess just hangs without proceeding and p.communicate() never completes. I was hoping there might be a way to add a command line flag to pass in a default response to this prompt (somewhat like -y for sudo apt-get install).

    fixed 
    opened by abelsonlive 7
  • Added password support for all archivers

    Added password support for all archivers

    Added password support for all archivers, which support work with password: arc, arj, p7zip, py_zipfile, rar, unace, unalz, unzip, xdms. Added tests for those, which support creation and test files in data folder for it.

    I checked every manual for all programs on my Ubuntu and on the Internet, if I find support for password, I added it. I added new tests for every changed programs, and added test archive for them if it's possible to create. For example I can't add test files for unace, unalz, xdms and etc. I can make it, if somebody send me archived files encrypted with password "thereisnotry" (I choose it as default for tests).

    It's my first open source commit, I'm pretty new in it, so will do my best to answer any comments ASAP.

    opened by Swich1987 5
  • Mime types

    Mime types

    I offer to edit file "/usr/share/libfm/archivers.list" during installation. Lines for addition:

    [patool] create=patool create %F extract=patool extract %F extract_to=patool extract %F --outdir %d mime_types=application/x-rar;application/x-tar;application/zip;application/deb; (list must be longer)

    opened by belkka 5
  • patool cli not found

    patool cli not found

    First of all thanks for patool. It is appreciated.

    After following installation instructions on the following page (pip install patool) I see that patools is installed using 'pip list' which returns 'patool (1.7)'. However, I am unable to execute the command line interface 'patool extract myfile.rar'. patool can't be found in the path. Where can I find it?

    http://wummel.github.io/patool/

    opened by stevensouza 5
  • Execution of 7z binary hangs for existing output files

    Execution of 7z binary hangs for existing output files

    7z prompts the user to confirm whether an existing file should be overwritten. This cause the process to hang since the user is unable to supply a response to the 7z process. The program supports the -y option to answer yes to all prompts; overwriting all existing output files. patool should supply -y if the 7z binary is used in order to make the behavior consistent with other tools such as gunzip and tar.

    question fixed 
    opened by pgiblock 4
  • Lack good documentation on how to use patool on Windows

    Lack good documentation on how to use patool on Windows

    I was looking for a global tool to extract files on windows server with python django . After checking couple of other libraries i tried patool.

    On some research it looks that tool is good but then it really lacks good documentation . First of all i couldnt install it in Windows by just doing

    pip install patool or python setup.py install

    To Install it i have to copy patoolib in my working directory and then import patoolib and this information is not documented anywhere .

    secondly patoolib supports TAR, ZIP, BZIP2 and GZIP and even tar.gz and its really impressive however it dosent support all other extension without helper applications .

    Lets take example of rar . it supports rar but it needs helper rar application and it lacks documentation on how to install that helper application and where to set path for it to run a working example .

    I tried various things and in the end finally i entered the path of unrar.exe file in the patoolib file to make it working . It works and it great but really lacks documentation .

    in my case adding the path of unrar.exe in patoolib file helped me i.e. in patoolib under ArchivePrograms = {} dictionary with values being ArchivePrograms = { 'rar': { None: ('rar',), 'extract': ('unrar'), 'list': ('unrar', '7z'), 'test': ('unrar', '7z'), }, }

    change value to ArchivePrograms = { 'rar': { None: ('rar',), 'extract': ('D:\UnRAR.exe', '7z'), 'list': ('D:\UnRAR.exe', '7z'), 'test': ('D:\UnRAR.exe', '7z'), }, }

    where 'D:\UnRAR.exe' is the path of windows unrar application .

    What i mean it this should be documented somewhere .

    fixed 
    opened by PaarthBatra 4
  • make test error

    make test error

    When I tried packaging patool, some error occured.

    patoolib/init.py:446:


    filename = '/home/rpmaker/rpmbuild/BUILD/patool-1.2/tests/data/t.txt.lzma.foo'

    def get_archive_format (filename):
        """Detect filename archive format and optional compression."""
        mime, compression = util.guess_mime(filename)
        if not (mime or compression):
    
          raise util.PatoolError("unknown archive format for file `%s'" % filename)
    

    E PatoolError: unknown archive format for file `/home/rpmaker/rpmbuild/BUILD/patool-1.2/tests/data/t.txt.lzma.foo'

    patoolib/init.py:277: PatoolError

    opened by cicku 4
  • patool and Python 3

    patool and Python 3

    As I've read on PyPI you doesn't support Python3 (no classifiers for that). On the site you say that patool have support for specific versions of Python.

    Please, update classifiers

    fixed 
    opened by eirnym 3
  • patool doesn't create usable patool.bat/.exe on windows

    patool doesn't create usable patool.bat/.exe on windows

    running pip install patool (within virtualenv) does create patool python script (without .py extension) which is useless on windows since what is needed is an obscure .exe which would call into that script. So far the most straightforward way to generate such .exe files I found is to use machinery available within setuptools and which it provides for entry_points, see e.g. primitive setup.py of ours: https://github.com/yarikoptic/datalad/blob/nf-custom-remotes/setup.py#L30 where we tell it to create two cmdline scripts invoking two different cmdline handlers.

    Unfortunately patool's setup.py is too evolved for me to provide any complete recipe here, if only I knew more why inno scripts etc.

    Cheers

    enhancement 
    opened by yarikoptic-private 3
  • Patool `oops I did it again` error

    Patool `oops I did it again` error

    I believe the issue has something to do with invalid Unicode on Windows which some of my files appear to have.

    ********** Oops, I did it again. *************

    You have found an internal error in patool. Please write a bug report at https://github.com/wummel/patool/issues/ and include at least the information below:

    Not disclosing some of the information below due to privacy reasons is ok. I will try to help you nonetheless, but you have to give me something I can work with ;) .

    <class 'UnicodeEncodeError'> 'charmap' codec can't encode characters in position 40-43: character maps to Traceback (most recent call last): File "C:\Users\Natan\AppData\Local\pypoetry\Cache\virtualenvs\aigrader-JJoG15ws-py3.10\Scripts\patool", line 213, in main res = globals()"run_%s" % args.command File "C:\Users\Natan\AppData\Local\pypoetry\Cache\virtualenvs\aigrader-JJoG15ws-py3.10\Scripts\patool", line 33, in run_extract patoolib.extract_archive(archive, verbosity=args.verbosity, interactive=args.interactive, outdir=args.outdir) File "C:\Users\Natan\AppData\Local\pypoetry\Cache\virtualenvs\aigrader-JJoG15ws-py3.10\lib\site-packages\patoolib_init_.py", line 683, in extract_archive util.log_info("Extracting %s ..." % archive) File "C:\Users\Natan\AppData\Local\pypoetry\Cache\virtualenvs\aigrader-JJoG15ws-py3.10\lib\site-packages\patoolib\util.py", line 516, in log_info print("patool:", msg, file=out) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 40-43: character maps to System info: patool 1.12 Python 3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)] on win32 Local time: 2022-12-22 21:42:09+003 sys.argv ['C:\Users\Natan\AppData\Local\pypoetry\Cache\virtualenvs\aigrader-JJoG15ws-py3.10\Scripts\patool', '--non-interactive', 'extract', [REMOVED FOR PRIVACY]]

    ******** patool internal error, over and out ********

    opened by NatanFreeman 0
  • CVE-2007-4559 Patch

    CVE-2007-4559 Patch

    Patching CVE-2007-4559

    Hi, we are security researchers from the Advanced Research Center at Trellix. We have began a campaign to patch a widespread bug named CVE-2007-4559. CVE-2007-4559 is a 15 year old bug in the Python tarfile package. By using extract() or extractall() on a tarfile object without sanitizing input, a maliciously crafted .tar file could perform a directory path traversal attack. We found at least one unsantized extractall() in your codebase and are providing a patch for you via pull request. The patch essentially checks to see if all tarfile members will be extracted safely and throws an exception otherwise. We encourage you to use this patch or your own solution to secure against CVE-2007-4559. Further technical information about the vulnerability can be found in this blog.

    If you have further questions you may contact us through this projects lead researcher Kasimir Schulz.

    opened by TrellixVulnTeam 0
  • "internal error" when extracting a RAR into an inexistent --outdir

    I’m using patool to extract several archives of various types and size, and I got this error when extracting RAR into an inexistent --outdir. All other formats I’ve tried patool on recovered from this exception, RAR seems to be the only type to fail hard.

    patool: Extracting /tmp/tmpuqlgbwkr.rar ...
    patool: running /usr/bin/unrar x -p- -y -- /tmp/tmpuqlgbwkr.rar
    patool:     with cwd='/home/grwth0/Data/savannah_cache/packages/nexusmod/skyrimspecialedition/5336/11851/files'
    
    
    ********** Oops, I did it again. *************
    
    You have found an internal error in patool. Please write a bug report
    at https://github.com/wummel/patool/issues/ and include at least the information below:
    
    Not disclosing some of the information below due to privacy reasons is ok.
    I will try to help you nonetheless, but you have to give me something
    I can work with ;) .
    
    <class 'FileNotFoundError'> [Errno 2] No such file or directory: '/home/grwth0/Data/savannah_cache/packages/nexusmod/skyrimspecialedition/5336/11851/files'
    Traceback (most recent call last):
      File "/usr/lib/python-exec/python3.10/patool", line 213, in main
        res = globals()["run_%s" % args.command](args)
      File "/usr/lib/python-exec/python3.10/patool", line 33, in run_extract
        patoolib.extract_archive(archive, verbosity=args.verbosity, interactive=args.interactive, outdir=args.outdir)
      File "/usr/lib/python3.10/site-packages/patoolib/__init__.py", line 684, in extract_archive
        return _extract_archive(archive, verbosity=verbosity, interactive=interactive, outdir=outdir, program=program)
      File "/usr/lib/python3.10/site-packages/patoolib/__init__.py", line 484, in _extract_archive
        run_archive_cmdlist(cmdlist, verbosity=verbosity)
      File "/usr/lib/python3.10/site-packages/patoolib/__init__.py", line 421, in run_archive_cmdlist
        return util.run_checked(cmdlist, verbosity=verbosity, **runkwargs)
      File "/usr/lib/python3.10/site-packages/patoolib/util.py", line 224, in run_checked
        retcode = run(cmd, **kwargs)
      File "/usr/lib/python3.10/site-packages/patoolib/util.py", line 216, in run
        res = subprocess.call(cmd, **kwargs)
      File "/usr/lib/python3.10/subprocess.py", line 345, in call
        with Popen(*popenargs, **kwargs) as p:
      File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/usr/lib/python3.10/subprocess.py", line 1847, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: '/home/grwth0/Data/savannah_cache/packages/nexusmod/skyrimspecialedition/5336/11851/files'
    System info:
    patool 1.12
    Python 3.10.8 (main, Nov 14 2022, 12:01:09) [GCC 11.3.0] on linux
    Local time: 2022-11-22 01:28:04-004
    sys.argv ['/usr/lib/python-exec/python3.10/patool', '--non-interactive', 'extract', '--outdir', '/home/grwth0/Data/savannah_cache/packages/nexusmod/skyrimspecialedition/5336/11851/files', '/tmp/tmpuqlgbwkr.rar']
    LANG = 'C.UTF8'
    
     ******** patool internal error, over and out ********
    
    
    opened by bbergeron0 0
  • Please support zstd format `.zst`

    Please support zstd format `.zst`

    > patool extract test.tar.zst
    patool: Extracting test.tar.zst ...
    patool error: error extracting test.tar.zst: unknown archive format for file `test.tar.zst'
    

    patool 1.12

    opened by Delta-in-hub 0
Command line tool for monitoring changes of File entities scoped in a Synapse File View

Synapse Monitoring Provides tools for monitoring and keeping track of File entity changes in Synapse with the use of File Views. Learn more about File

Sage Bionetworks 3 May 28, 2022
cmsis-pack-manager is a python module, Rust crate and command line utility for managing current device information that is stored in many CMSIS PACKs

cmsis-pack-manager cmsis-pack-manager is a python module, Rust crate and command line utility for managing current device information that is stored i

pyocd 20 Dec 21, 2022
Notion-cli-list-manager - A simple command-line tool for managing Notion databases

A simple command-line tool for managing Notion List databases. ✨

Giacomo Salici 75 Dec 4, 2022
🔖 Lemnos: A simple, light-weight command-line to-do list manager.

?? Lemnos: CLI To-do List Manager This is a simple program that allows one to manage a to-do list via the command-line. Example $ python3 todo.py add

Rohan Sikand 1 Dec 7, 2022
A cd command that learns - easily navigate directories from the command line

NAME autojump - a faster way to navigate your filesystem DESCRIPTION autojump is a faster way to navigate your filesystem. It works by maintaining a d

William Ting 14.5k Jan 3, 2023
AML Command Transfer. A lightweight tool to transfer any command line to Azure Machine Learning Services

AML Command Transfer (ACT) ACT is a lightweight tool to transfer any command from the local machine to AML or ITP, both of which are Azure Machine Lea

Microsoft 11 Aug 10, 2022
Ros command - Unifying the ROS command line tools

Unifying the ROS command line tools One impairment to ROS 2 adoption is that all

null 37 Dec 15, 2022
Shazam is a Command Line Application that checks the integrity of the file by comparing it with a given hash.

SHAZAM - Check the file's integrity Shazam is a Command Line Application that checks the integrity of the file by comparing it with a given hash. Crea

Anaxímeno Brito 1 Aug 21, 2022
Baseline is a cross-platform library and command-line utility that creates file-oriented baselines of your systems.

Baselining, on steroids! Baseline is a cross-platform library and command-line utility that creates file-oriented baselines of your systems. The proje

Nelson 4 Dec 9, 2022
This is a tool for managing file notes through the command line

This is a tool for managing file notes through the command line

null 2 Jun 22, 2022
inklayers is a command line program that exports layers from an SVG file.

inklayers is a command line program that exports layers from an SVG file. It can be used to create slide shows by editing a single SVG file.

null 11 Mar 29, 2022
A command-line utility that, given a markdown file, checks whether all its links work.

A command-line utility written in Python that checks validity of links in a markdown file.

Teclado 2 Dec 8, 2021
OneDriveExplorer - A command line and GUI based application for reconstructing the folder structure of OneDrive from the UserCid.dat file

OneDriveExplorer - A command line and GUI based application for reconstructing the folder structure of OneDrive from the UserCid.dat file

Brian Maloney 100 Dec 13, 2022
Container images for portable development environments

Docker Dev Spin up a container to develop from anywhere! To run, just: docker run -ti aghost7/nodejs-dev:boron tmux new Alternatively, if on Linux: p

Jonathan Boudreau 163 Dec 22, 2022
Vsm - A manager for the under-utilized mksession command in vim

Vim Session Manager A manager for the under-utilized `mksession` command in vim

Matt Williams 3 Oct 12, 2022
TUIFIManager - A cross-platform terminal-based file manager

TUIFI Manager A cross-platform terminal-based file manager (and component), mean

null 142 Dec 26, 2022
commandpack - A package of modules for working with commands, command packages, files with command packages.

commandpack Help the project financially: Donate: https://smartlegion.github.io/donate/ Yandex Money: https://yoomoney.ru/to/4100115206129186 PayPal:

null 4 Sep 4, 2021
A Python-based command prompt concept which includes windows command emulation.

PythonCMD A Python-based command prompt concept which includes windows command emulation. Current features: echo: Input your message and it will be cl

null 1 Feb 5, 2022