Created
February 27, 2021 23:22
-
-
Save rodrigorega/a893ce877aee4822e08ff2eacdfac7b7 to your computer and use it in GitHub Desktop.
Uncompress all .zip and .rar files in the current directory and delete after uncompress
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
#!/bin/bash | |
# Descomprimir todos los .zip y .rar del directorio actual y borra | |
# el archivo original tras la estracción. Se usa 7z ya que facilita la | |
# extracción a un directorio independiente. | |
# Es necesario tener soprote para .rar en 7z: | |
# apt install p7zip-rar | |
for filename in *.zip *.rar; do | |
# "my_password" es un password aleatorio para que falle por password | |
# inválido en vez de estar esperando a que se introduzca manualmente | |
7z x -pmy_password "${filename}" -o'*' -aou | |
if [ $? -eq 0 ]; then | |
rm -v "${filename}" | |
else | |
echo "Extracción fallida, no se borra ${filename}". | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment