Extracting tar.gz file

Hi, I’m trying to deal with a variety of compressed files, but if I use the ditto shell command, sometimes I get an error extracting tar.gz files. I’ve looked around and it seems like there is something wrong with the file which gives the error with the shell command. It opens fine if I just double click on it, but if use something like:

tell application “System Events” to open theFile

then there are obtrusive progress bars and a finder window pops up at the end. Also, I’d like to extract the file into another directory. At the very least, I would like to be able to prevent the popup at the end.

I’ve also tried other shell commands such as gunzip and tar, but I couldn’t get these to work at all. I would really appreciate any help you can give me. Thanks,

-Matt

Hi,

I just tested the following code and it works just fine. Of course, you will need to adjust the paths to your requirements:


-- path to the gzipped tape archive
set archivefilepath to "Macintosh HD:Users:martin:Desktop:amhello-1.0.tar.gz"
set qtdarchivefilepath to quoted form of POSIX path of archivefilepath
-- path to the destination directory
set destdirectory to "Macintosh HD:Users:martin:Desktop:test:"
set qtddestdirectory to quoted form of POSIX path of destdirectory
-- building and executing the shell command which extracts the archive into the destination directory
set command to "cd " & qtddestdirectory & ";/usr/bin/tar xvfz " & qtdarchivefilepath
do shell script command

Best regards from autumnly Berlin,

Martin

That worked great! Thanks so much