Results 1 to 6 of 6

Thread: unraring en masse in bash

  1. #1
    Join Date
    May 2009
    Location
    New York
    Beans
    109
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    unraring en masse in bash

    Basically I have a folder of .rar files that I want to unrar. I have been using the following script:

    for name in *.rar; do unrar x $name; done

    The script works excellently, except for one thing: all of the files have the same password, and I have to manually type the password every single time. So what I try is

    for name in *.rar; do unrar x $name -p<thepassword>; done

    But that doesn't work. Help please?

  2. #2
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: unraring en masse in bash

    It works for me. Are you sure that the password is correct? Linux is case sensitive. Does it contain any special characters or spaces? Do you get any error message?

    EDIT:
    You don't have to separate the -p option from the password by a space.

    Code:
    for name in *.rar; do unrar x $name -ppassword; done
    (Assuming that the password is password.)
    Last edited by sisco311; January 26th, 2010 at 12:41 AM.

  3. #3
    Join Date
    Jun 2009
    Beans
    1,618
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: unraring en masse in bash

    I think sisco means there *should* be a space there...

    Also, if your pass includes spaces, quote it.

    Also, shoulden't that x be -x?

    Code:
    for name in *.rar; do unrar -xp "password" $name; done
    Comitas. Brevitas. Nulla ambitio.

  4. #4
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: unraring en masse in bash

    Quote Originally Posted by J V View Post
    I think sisco means there *should* be a space there...
    I mean, the -p switch should not be separated from its argument by a space.

    The correct syntax is:
    Code:
    unrar x file.rar -ppassword
    where file.rar is the name of the archive & password is the password.

  5. #5
    Join Date
    Jun 2009
    Beans
    1,618
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: unraring en masse in bash

    Thats what it says in the manual, but I think its a spelling error, not good bash standard :/
    Comitas. Brevitas. Nulla ambitio.

  6. #6
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: unraring en masse in bash

    Quote Originally Posted by J V View Post
    Thats what it says in the manual, but I think its a spelling error, not good bash standard :/
    No, it's not. You can try it:
    Code:
    > file
    rar a -phpassword file.rar file
    rm file
    unrar x -ppassword file.rar
    a and x (add/extract) are commands passed to rar and unrar, just like apt-get install or apt-get purge. -ph and -p are switches like grep -A5 or fsck -C0.

    It may look awkward, but the syntax is not uncommon.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •