Hey, I hope I'm posting this in the right forum. I'm compressing a bunch of files to tar.gz, then uploading them to my webhosts ftp server, and then trying to uncompress them on my server using a php script that enables me to run some shell commands (since we don't have shell access).

The command I'm using right now is "tar xzf archivename.tar.gz"

The problem with this is, the archive consists of files within directories, within directories. But when I extract them, it extracts everything to the same directory, and appends the directory path to the file names, rather then putting them all in their own directories.

What command do I use to extract them while keeping the directory structure in place?


tar keeps the directory path in place by default. This behaviour that your describing would be very unusual for a tar command. Something special is being done, probably an alias replacing tar with a special call (although I don't know of any options to tar that would cause this behaviour), or some options were used (again I don't any , but then again I have only Sun's tar for comparison and Gnu's tar has many more options) on the packaging tar command that caused this.

It very well could be the app I'm using to package the tar in the first place that is causing the problem. It has absolutely no options at all. The app I'm using is free and can be obtained here. You simply drag and drop the files you want to compress onto the box, and that's it. No options at all. Any suggestions for a good free app to do it? Maybe that's my problem.

thanks guys. I actually found that powerarchive works great.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.