Welcome, guest | Sign In | My Account | Store | Cart

This recipe is meant to be used as a commmand line *.tar.gz file extractor. If it fails, then a usage note is given. It may be small, but it can be very useful for some people.

Python, 10 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
import os, sys, tarfile

try:
    tar = tarfile.open(sys.argv[1] + '.tar.gz', 'r:gz')
    for item in tar:
        tar.extract(item)
    print 'Done.'
except:
    name = os.path.basename(sys.argv[0])
    print name[:name.rfind('.')], '<filename>'

The purpose for which this program was written is that Windows does not come with a *.tar.gz extractor. If Python is installed on someones machine, this small program should be all that that person needs. It is not perfect, but it gets the job done. More options could certainly be added to this program, but it was written by someone in a hurry. :)

1 comment

windows user 14 years, 8 months ago  # | flag

Nice script Stephen Chappell.

For those who do not have python set up and just want a simple command line too to extract *.tgz or *.tar.gz file tartool is a good option http://tartool.codeplex.com.

Its completely open source too!