Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been Googleing for a few hours on how to just compress a file inside a directory and I can't find anything. I found how to just compress a folder in general. Now I wish to know how I can compress a folder in a folder with a file. Current code:

7zG.exe a -tzip "test.zip" dontcompressme/compressme/new.txt
pause

As you can see above, I don't want to compress the first folder, but only the second and what ever is within that folder. I have the 7zG.exe sitting in the main folder and I have some files that are three folders in, but I don't know how to only compress those. Here is my directory list:

  • Folder One (don't compress)
    • Folder Two (don't compress)
      • Folder Three (okay to compress)
        • Document One.txt (okay to compress)
        • Document Two.txt (okay to compress)
        • Index.html (okay to compress)

Does anyone know how I can do this in the most simplest way ever invented by man? Cause whenever I go to a website using Google it goes throw all these methods on how to compress a folder, but not do it the way I wish it to do. It makes me kinda upset cause I can't get a simple and straight forward answer. Thank you if you answer my question.

share|improve this question

migrated from stackoverflow.com Nov 4 '11 at 16:49

This question came from our site for professional and enthusiast programmers.

pushd "Folder One\Folder Two"
7za a -tzip ..\..\test.zip "Folder Three"
popd
share|improve this answer
    
Works great, but how would I have PHP exec this command? – OneTwoYou Nov 3 '11 at 21:39
    
You'd have to tell PHP to change the current directory, then execute the command. chdir looks like a good candidate for the first part. – afrazier Nov 4 '11 at 19:01

You must log in to answer this question.