I am trying to zip up the following directory contents:


I want to be able to zip up the Test directory and the bin subdirectory, however, I need the Test directory’s contents to be the root of the archive.

Using the WinRAR command-line program (rar.exe), I tried this command:

"C:\File.zip" -ep "C:\Test"

However, this puts all the folder contents in root of the archive. I also tried the following command, but got the same results:

"C:\File.zip" -ep "C:\Test\*.*" "C:\Test\bin"

How can I get the results I’m trying to achieve?

  • 1
    r is the switch for recursive – RobotHumans Jun 28 '11 at 15:46
  • x and x@ allow you to disallow files – RobotHumans Jun 28 '11 at 15:47
  • 1
    @aking, the -r switch will also add everything else that is in C:\Test, which Lee has not said is desired. – Synetech Aug 15 '11 at 6:14

You are using the -ep switch which Exclude[s] paths from names. If paths are not stored, then all files go in the root.

To get C:\Test to be treated as the root of the archive, you need to run the compression from inside the directory.

Use this instead:

C:\>cd Test

C:\Test>:: then, either
C:\Test>rar a "C:\File.zip" "*.*" "bin\*.*"

C:\Test>:: or
C:\Test>rar a "C:\File.zip" "*.*" "bin"

It is possible by:

rar a -ep1 -r "C:\File.zip" "." "bin\*.*" 

-ep1 = Do not store the path entered at the command line in archive. Exclude base folder from names.

-r: recurses subfolders

It worked for me!

http://comptb.cects.com/2503-using-the-winrar-command-line-tools-in-windows http://www.qa.downappz.com/questions/winrar-command-line-to-add-files-with-relative-path-only.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.