dtrx: Intelligent archive extraction


dtrx stands for “Do The Right Extraction.” It's a tool for Unix-like systems that takes all the hassle out of extracting archives. Here's an example of how you use it:

$ dtrx linux-3.0.1.tar.bz2

That's basically the same thing as:

$ tar -jxf linux-3.0.1.tar.bz2

But there's more to it than that. You know those really annoying files that don't put everything in a dedicated directory, and have the permissions all wrong?

$ tar -zvxf random-tarball.tar.gz
$ cd data/
cd: permission denied: data

dtrx takes care of all those problems for you, too:

$ dtrx random-tarball.tar.gz
$ cd random-tarball/data
$ cat text
This all works properly.

dtrx is simple and powerful. Just use the same command for all your archive files, and they'll never frustrate you again.



Download dtrx 7.1. The SHA1 checksum for this file is 05cfe705a04a8b84571b0a5647cd2648720791a4. Improvements in this release include:

If you would like to try the latest development version—or maybe do some work on it yourself—you can check out the project's Mercurial repository. A web repository is available, or you can just run:

$ hg clone http://www.brettcsmith.org/2007/dtrx/dtrx


If you have Python 2.4 or greater, this should work out of the box. If you're stuck on Python 2.3, you can use this if you install the subprocess module. You'll need the usual tools for the archive types you want to extract: for example, if you're extracting zip files, you'll need zipinfo and unzip. See the INSTALL file included with dtrx for a complete list of necessary utilities.


You can just put scripts/dtrx wherever is convenient for you, but if you want to install the program system-wide, you can also run the following command as root or equivalent:

python setup.py install --prefix=/usr/local

See the included INSTALL file for more information.