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.
1 2 3 4 5 6 7 8 9 10
import os, sys, tarfile try: tar = tarfile.open(sys.argv + '.tar.gz', 'r:gz') for item in tar: tar.extract(item) print 'Done.' except: name = os.path.basename(sys.argv) 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. :)