RAR - folder without saving the full path

1) I have a folder named CCBuilds containing a couple of files in this path -> E: \ Testing \ Builds \ CCBuilds.

2) I wrote C # code (Process.Start) in Rar of this folder and saved it in E: \ Testing \ Builds \ CCBuilds.rar using the following command

"C: \ program files \ winrar \ rar.exe a E: \ Testing \ Builds \ CCBuilds.rar E: \ Testing \ Builds \ CCBuilds"

3) The problem is that although the rar file is created correctly when I deploy the file to the CCBuilds2 folder (both using code using the "rar.exe x" command and using Extract in the context menu), in the infrared folder contains the full path: i.e.: extracting E: \ Testing \ Builds \ CCBuilds.rar → E: \ testing \ Builds \ CCBuilds2 \ testing \ Builds \ CCBuilds \ <>

While I want it to be something like this: E: \ testing \ Builds \ CCBuilds2 \ CCBuilds \ <>

How can I avoid this full path preservation when added to rar / extracted from it. Any help is appreciated.

+4
source share
3 answers

Use the -ep1 switch.

Additional Information:

-ep = Files are added to the archive, not including path information. May result in multiple files in the archive with the same name.

-ep1 = Do not save the path specified on the command line in the archive. Exclude the base folder from the names.

-ep2 = Expand the path to full. Keep full paths to files (except drive letter and leading backslash) when archiving.

(source: http://www.qa.downappz.com/questions/winrar-command-line-to-add-files-with-relative-path-only.html )

+18
source

Just in case, this helps: I'm currently working on a MS Access database project (customer relationship management for a small company), and one of the tasks is to send zip docx files to clients, with a specific password encryption being used.

In a VBA procedure that starts zip-packing docx files, I call WinRAR as follows:

c:\Programme\WinRAR\winrar.exe a -afzip -ep -pThisIsThePassword "OutputFullName" "InputFullName" 

-afzip says: "Create a zip file (as opposed to a rar file)

-ep says: do not include the paths of the source file, i.e. put the file directly in the zip folder

A complete list of such switches is available in WinRAR Help, section "Command Prompt".

+1
source

x retrieves it as E: \ Testing \ Builds \ CCBuilds2 \ Testing \ Builds \ CCBuilds \ because you use the full path when declaring the source. Either use -ep1, or set the default working directory to E: \ Testing \ Builds.

Using -ep1 is necessary, but it is a bit complicated.
If you use:

Winrar.exe output path
Winrar.exe a E: \ Testing \ Builds \ CCBuilds.rar E: \ Testing \ Builds \ CCBuilds

it will include the input path declared:

E: \ Testing \ Builds \ CCBuilds → E: \ Testing \ Builds \ CCBuilds.rar:
Testing \ Builds \ CCBuilds \ file1
Testing \ Builds \ CCBuilds \ file2
Testing \ Builds \ CCBuilds \ folder1 \ file3
...

which will eventually be unpacked, as you mentioned:

E: \ Testing \ Builds \ CCBuilds2 \ Testing \ Builds \ CCBuilds \

There are two ways to use -ep1.

If you want a simple way:

E: \ Testing \ Builds \ CCBuilds \

be extracted as:

E: \ Testing \ Builds \ CCBuilds2 \ CCBuilds \ file1
E: \ Testing \ Builds \ CCBuilds2 \ CCBuilds \ file2
E: \ Testing \ Builds \ CCBuilds2 \ CCBuilds \ path1 \ file3
...

using

Winrar.exe a -ep1 E: \ Testing \ Builds \ CCBuilds.rar E: \ Testing \ Builds \ CCBuilds

files inside the archive will look like this:

CCBuilds \ file1
CCBuilds \ file2
CCBuilds \ folder1 \ file3
...

or you can use ep1 to simply add files and folder structure without a base folder using recursion and define the base path as the internal path of the structure:

Winrar.exe a -ep1 -r E: \ Testing \ Builds \ CCBuilds.rar E: \ Testing \ Builds \ CCBuilds \ *

Files:

E: \ Testing \ Builds \ CCBuilds \ file1
E: \ Testing \ Builds \ CCBuilds \ file2
E: \ Testing \ Builds \ CCBuilds \ folder1 \ file3
...

inside the archive will look like this:

file1
file2
folder1 \ file3
...

after extraction it will look like this:

E: \ Testing \ Builds \ CCBuilds2 \ file1
E: \ Testing \ Builds \ CCBuilds2 \ file2
E: \ Testing \ Builds \ CCBuilds2 \ folder1 \ file3
...

In any case, these two methods -ep1 can be used to exclude the base path with or without a folder containing files (base folder / or base path).

0
source

Source: https://habr.com/ru/post/1401175/


All Articles