scripts/extract

17 lines
435 B
Plaintext
Raw Normal View History

2017-02-18 09:39:31 +02:00
#!/bin/sh
for archive in "$@"; do
# count files in root dir
rootfiles=$(7z l -slt "${archive}" | grep -c 'Path = [^/]*$')
# add -o switch, if more than one file in root
# checks for >2, because path of the zip file itself is listed too
if [ $rootfiles -gt 2 ]; then
filename=${archive##*/}
rootname=${filename%.*}
opt="-o${rootname}"
fi
#unpack
7z x "${opt}" "${archive}"
done