linux – unzip multiple files and folders with different compression formats and passwords

Some time ago I asked this question and posted my bash script,to decompress multiple files, in different compression formats, with different passwords:

PASS="passfoo passbar passfoobar"
LIST=$(ls -1 *.{zip,7z,7z.001,rar})
for password in $PASS; do
  OIFS="$IFS"
  IFS=$'n'
  for i in $LIST
  do
      echo "$password"
      7z x -y -p"$password" "$i" -aoa
      if ( $? -eq 0 ); then
     continue
    fi
   done
   IFS="$OIFS"
  done

And I selected this answer as correct:

#!/usr/bin/env bash

shopt -s extglob nullglob

passw=(
  passfoo
  passbar
  passfoobar
  banana
  chocolate
  whiskey
  vodka
  icecream
)

for f in *.@(zip|7z|7z.001|rar); do
  for p in "${passw(@)}"; do
    if 7z x -y -p"$p" "$f" -aoa; then
      break
    fi
  done
done

But my script still contained errors with multipart .rar files. So I asked another question, and received an answer that fixed the problem, leaving the script as follows:

#!/usr/bin/env bash
shopt -s extglob nullglob nocaseglob
passw=(
  foo
  bar
)
for f in *.@(rar|zip|zip.001|7z|7z.001); do
  (( ( "$f" =~ .part((:digit:))+.rar$ ) && ! ( "$f" =~ .part0*1.rar$ ) )) && continue
  for p in "${passw(@)}"; do
    if 7z x -y -p"$p" "$f" -aoa; then
      break
    fi
  done
done

But my script still has problems. For example:

  1. when the script tries to unzip a compressed file that has an error preventing it from unzipping, the script runs indefinitely

  2. When the script tries to unzip a file that contains a folder with different files, the script tries to unzip the files inside the folder (ok), but even those that do not have a compression extension (e.g.: * .url) and get ERROR CRC wrong password and keep running and testing every password of the script trying to unzip uncompressed files

some help?