Rar.exe CLI - add files from directory without directory structure?

6,320

After reading the manual the 3rd time, I found the -ep switch.

-ep     Exclude paths from names. This switch enables files to be added
        to an archive without including the path information. This
        could, of course, result in multiple files existing in the
        archive with the same name.

I first misunderstood this because, as far as I know, path refers to directory and file name, thinking that it would strip the name completely from the files.
(this belief is due to my experience with other archive formats)

However, by path, the author meant directory.
A word of warning, it will strip all directory information (even from sub-directories), flattening the file structure.

Share:
6,320

Related videos on Youtube

Vercas
Author by

Vercas

There is so much code waiting to be written...

Updated on September 18, 2022

Comments

  • Vercas
    Vercas over 1 year

    I need to grab every file in a folder and shove it into a RAR archive.

    This is my current method:

    "C:\Program Files\WinRAR\Rar.exe" a -r -md2m -s -m5 -ma4 -t ..\Releases\vCommands.rar bin\
    

    ... Where bin is my folder. I tried this too, even though it is for another program, and the results are the same.

    To be clear, here's a picture:
    difference

    To the top-left, in the .rar file, there is the bin directory which contains all the files.
    To the bottom-right, in the .7z file, all those files are in the archive root.

    What I need is shoving all those files in the .rar archive root, instead of a folder, without having to execute my batch file inside that bin folder.

  • Vercas
    Vercas almost 10 years
    Holy Lord, that creates every folder from the drive root up to the files in the archive.
  • Vercas
    Vercas almost 7 years
    Polluting PATH on Windows is baaaad. :(