• 0

Rar Scripting Help Required


Question

I am trying to make a batch file to compress the contents of many directories, while I have a script that works, I must be missing something as I have told rar not to store the base directory name using the -ep1 switch (or I think I have) but it still stores it.

 

Just to be clear I have no clue about scripting and was lucky to get it working from a few hours googling :p

 

 

The folders are laid out like so

Name of product 1
     |_folder 1
     |_folder 2
     |_folder 3

Name of product 2
     |_folder 1

Name of product 3
     |_folder 1
     |_folder 2

And so on, what I am trying to do is get rar to omit "Name of product x" folder name in order to have a rar file that looks like

Name of product 1.rar
folder 1
folder 2
folder 3

Name of product 2.rar
folder 1

Name of product 3.rar
folder 1
folder 2

the script so far looks like this

@echo off
for /d  %%G in ("*") do (
"%programfiles%\WinRAR\Rar.exe" a "%%G.rar" -ep1 "%%G" -r -m5 -ma5 -md32m -rr2 -s
)

Although I have moved it about a bit no matter what I try it doesn't work and I end up with a rar named after the base directory which I want, but in the rar it has kept the base folder as well.

 

Any help is greatly appricated

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

the solution was to add \*, something I overlooked in my tired state

@echo off
for /d  %%G in ("*") do (
"%programfiles%\WinRAR\Rar.exe" a -ep1 -r -m5 -ma5 -md32m -rr2 -s "%%G.rar" "%%G\*"
rd /s /q "%%G"
)

the line I added was to delete the folders after they were added to the rar file

Link to comment
Share on other sites

  • 0

SOLVED

 

You should post the solution for people who Google and find this in the future, their's nothing more annoying than finding a thread in the future where the solution was never shared.

 

Recent proof people appreciate this: link

Link to comment
Share on other sites

This topic is now closed to further replies.