This repository has been archived by the owner on Dec 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added Extract Password Protected Archive Files - Many minor bug fixed
- Loading branch information
1 parent
d760da4
commit fe22b1c
Showing
5 changed files
with
219 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
#!/bin/bash | ||
|
||
if [ $# -lt 1 ]; then | ||
echo "Usage: $(basename $0) FILES" | ||
exit 1 | ||
fi | ||
|
||
extract() { | ||
arg="$1" | ||
pswd="$2" | ||
cd "$(dirname "$arg")" || exit | ||
case "$arg" in | ||
*.tar.bz2) | ||
tar xjf "$arg" --one-top-level | ||
local code=$? | ||
;; | ||
*.tar.gz) | ||
tar xzf "$arg" --one-top-level | ||
local code=$? | ||
;; | ||
*.bz2) | ||
bunzip2 "$arg" | ||
local code=$? | ||
;; | ||
*.gz) | ||
gunzip "$arg" | ||
local code=$? | ||
;; | ||
*.tar) | ||
tar xf "$arg" --one-top-level | ||
local code=$? | ||
;; | ||
*.tbz2) | ||
(tar xjf "$arg" --one-top-level) | ||
local code=$? | ||
;; | ||
*.tgz) | ||
tar xzf "$arg" --one-top-level | ||
local code=$? | ||
;; | ||
*.zip) | ||
a_dir=$(expr "$arg" : '\(.*\).zip') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.7z) | ||
a_dir=$(expr "$arg" : '\(.*\).7z') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.Z) | ||
uncompress "$arg" | ||
local code=$? | ||
;; | ||
*.rar) | ||
a_dir=$(expr "$arg" : '\(.*\).rar') | ||
mkdir "$a_dir" | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.iso) | ||
a_dir=$(expr "$arg" : '\(.*\).iso') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.wim) | ||
a_dir=$(expr "$arg" : '\(.*\).wim') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.cab) | ||
a_dir=$(expr "$arg" : '\(.*\).cab') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.apm) | ||
a_dir=$(expr "$arg" : '\(.*\).apm') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.arj) | ||
a_dir=$(expr "$arg" : '\(.*\).arj') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.chm) | ||
a_dir=$(expr "$arg" : '\(.*\).chm') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.cpio) | ||
a_dir=$(expr "$arg" : '\(.*\).cpio') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.cramfs) | ||
a_dir=$(expr "$arg" : '\(.*\).cramfs') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.deb) | ||
a_dir=$(expr "$arg" : '\(.*\).deb') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.dmg) | ||
a_dir=$(expr "$arg" : '\(.*\).dmg') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.fat) | ||
a_dir=$(expr "$arg" : '\(.*\).fat') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.hfs) | ||
a_dir=$(expr "$arg" : '\(.*\).hfs') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.lzh) | ||
a_dir=$(expr "$arg" : '\(.*\).lzh') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.lzma) | ||
a_dir=$(expr "$arg" : '\(.*\).lzma') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.lzma2) | ||
a_dir=$(expr "$arg" : '\(.*\).lzma2') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.mbr) | ||
a_dir=$(expr "$arg" : '\(.*\).mbr') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.msi) | ||
a_dir=$(expr "$arg" : '\(.*\).msi') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.mslz) | ||
a_dir=$(expr "$arg" : '\(.*\).mslz') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.nsis) | ||
a_dir=$(expr "$arg" : '\(.*\).nsis') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.ntfs) | ||
a_dir=$(expr "$arg" : '\(.*\).ntfs') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.rpm) | ||
a_dir=$(expr "$arg" : '\(.*\).rpm') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.squashfs) | ||
a_dir=$(expr "$arg" : '\(.*\).squashfs') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.udf) | ||
a_dir=$(expr "$arg" : '\(.*\).udf') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.vhd) | ||
a_dir=$(expr "$arg" : '\(.*\).vhd') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*.xar) | ||
a_dir=$(expr "$arg" : '\(.*\).xar') | ||
7z x "$arg" -o"$a_dir" -p"$pswd" | ||
local code=$? | ||
;; | ||
*) | ||
echo "'$arg' cannot be extracted via extract()" 1>&2 | ||
exit 1 | ||
;; | ||
esac | ||
cd - || exit $? | ||
exit $code | ||
} | ||
|
||
extract "$1" "$2" |