Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an Ubuntu Server and use rar with the exec() function. When I want to create a RAR archive from my files, this program uses their path in my RAR archive.

For example, if my file is in /home/user/video/some.flv and my php program is in /home/user, it will added as video/some.flv — however I want the file path to be some.flv.

I also don't want to copy my file to where my php program is, so I need a way to change the path. I used this:

rar rn archive.rar video/some.flv some.flv

… but when I try to extract it, it tells me the file label is "wrong or damaged". What can I do? I have many big files in different paths and want all of them to be in the root path of my RAR archive.

share|improve this question

You can try adding the -ep (exclude path) switch to rar. So when you add new files, it would be something like:

rar a -ep archive.rar video/some.flv

but rar should add it to the archive as simply some.flv.

share|improve this answer

I assume the command you execute (from your php app) is something like

rar a archive.rar video/some.flv

According to rar --help,

ep --- Exclude path from names

Adding the -ep like so

rar a -ep archive.rar video/some.flv

causes the paths to be omitted in the rar, and all the files you have added will show up in the folder they are extracted to and not in a subfolder.

I couldn't figure out how to do the same as tar's -C, but I hope this does what you needed.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .