Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

extract several archives with different passwords?

Help
Teddoh
2013-11-12
2013-11-14
  • Teddoh
    Teddoh
    2013-11-12

    Hello,
    I want to extract several archives with different passwords from a folder.
    Currently I'm using only: "7z e -pPASSWORD1 archivefolder\*.rar"

    But how can I add a second, third... password to extract all archives at once?

    Best regards
    Teddoh

     
  • Igor Pavlov
    Igor Pavlov
    2013-11-12

    7-zip can't change password now.
    So it can use only one password in one command.

     
  • Teddoh
    Teddoh
    2013-11-12

    oh, it's a pity... ;-(

    Thank you for your answer and your great tool.

    Best regards
    Teddoh

     
  • Teddoh
    Teddoh
    2013-11-14

    I worte a little shell/bash script and added it to my filemanager thunar.
    It's working and I'm happy... if someone need a similar solution:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    #!/bin/bash
    
    passwordlist=("Password 1" "Password 2" "Password 3" "Password 4" "Password 5")
    lastpass=$((${#passwordlist[@]} -1))
    
    for archive in *.{rar,zip,7z}
    do
        if [ "$archive" == "*.rar" -o "$archive" == "*.zip" -o "$archive" == "*.7z" ]
        then
            continue
        fi
    
        for password in "${passwordlist[@]}"
        do
            7z x -y -p"$password" "$archive"
            if [ $? == 0 ]
            then
                archivestatus+=("OK - $archive | Password: $password")
                break
            elif [ "$password" == "${passwordlist[$lastpass]}" ]
            then
                archivestatus+=("FAILED - $archive | Password: no matching password")
            fi
        done
    done
    
    # zenity is preinstalled on most ubuntu systems... if not:
    # sudo apt-get install zenity
    zenity --list --title="Finished - ${#archivestatus[@]} Archive(s)" --column="Status:" "${archivestatus[@]}"