i run this script but this have a problem with extract rar multiparts
#!/usr/bin/env bash
shopt -s extglob nullglob
passw=(
passfoo
passbar
passfoobar
banana
chocolate
whiskey
vodka
icecream
)
for f in *.@(rar|zip|zip.001|7z|7z.001); do
for p in "${passw[@]}"; do
if 7z x -y -p"$p" "$f" -aoa; then
break
fi
done
done
With .zip
or .7z
it decompresses the multiparts well, because the extension of the multiparts are equal (for .7z
= 7z.001
, 7z.002
, etc. For .zip
= zip.001
, zip.002
, etc). The problem is that if I add this to the script:
*.@(rar|part1.rar|zip|zip.001|7z|7z.001)
It fails because *.partX.rar
and .rar
both end in .rar and the loop unzips the same thing over and over again or fails in .part2.rar
onwards if the file has password
Failed attempts to fix the problem:
To exclude any file from
.part2.rar
(example:*.part{2..99}.rar
)With the switch "-x"
I appreciate help completing the loop and integrating decompression of multipart files in .rar
format
part[0-9].rar
in the loop maybe?