5

Suppose my folder structure is:

A

-B

--C

---D

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 up to folder A? I.e when someone extracts the .rar file they should see the folder hierarchy recreated and the file 'test.txt' within folder D, in this way:

A

-B

--C

---D

---test.txt

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

3 Answers3

0

You have a better way!

Seems like Store relative path is poorly implemented, but other options are fine. So you can:

  • right click on folder A
  • in the "Files to add", you navigate to test.txt and select, so it will be "C:/Users/A/B/C/D/test.txt", for example
  • You don't have to exclude any file
  • choose "Store full path" and confirm.

The file tree structure from Users to test.txt will be preserved. Maybe it's more than what you need, but you can always decompress the resulting package and take the part of path you need.

0

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.

RonK
  • 1,540
0

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