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

Suppose my folder structure is:





and in the D folder I have a file, say test.txt. How can I add this test.txt file to an archive so that the folder's hierarchy is also maintained in the zipped file? I.e when someone extracts the .rar file they should see it in this way:






I do not want the files of other folders (A B C) in my case.

share|improve this question
Happened to come across this question. I know it's perhaps too late, but did you mean you wanted just Test.txt in the RAR, and when you extracted it you would end up with folders A, A\B, A\B\C, A\B\C & A\B\C\D and the file A\B\C\D\Test.txt? If so, the accepted answer seems incorrect to me. There's no reason why you should have to manually exclude every other file in the (A B C) folders. – Karan Jun 4 '13 at 22:37
up vote 0 down vote accepted

The only way to do it is manually specify each file you do not want to be added in the Files tab.

winrar file exclusion

share|improve this answer

Right-Click on A and choosing Compress with WinRar should do the trick.

Unless of course if you have other files there which you want to exclude.

Edit: I have a solution based on Total Commander if applicable for you:

  1. Go to the parent directory of A
  2. Press on Ctrl+B to view a flat list of all the files under that directory (may take time depending on how many files you have - I tested 8sec for 9120 files)
  3. Select the file/files you want
  4. Press on Alt+F5 to select compression of the selected files, choose a name for the archive and a destination (default is the opposite pane) and click on OK.

Total Commander will know to create the directory structure automatically.

Another option if you need this on a permanent basis and the directory structure and the file name is also constant, you can simulate the directory structure on another location on your disk, and use Junction from the Sysinternals pack to create a link from the fake D folder to the real file - then you always have an empty folder structure of A->B->C->D->test.file and don't have to worry about junk in the archive.

share|improve this answer
"I do not want the files of other folders (A B C) in my case." – Sathya May 30 '11 at 11:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .