Last active
January 28, 2023 02:08
-
-
Save oscarmcm/8015985 to your computer and use it in GitHub Desktop.
Script para aligerar fotos / reducir calidad y tamañoPara que el script funcione es necesario tener instalado gawk.
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 | |
# Programa en bash que cambia recursivamente la calidad de todos los ficheros | |
# .jpg a una calidad del 80%. | |
func_convertir() | |
{ | |
for Fichero in * | |
do | |
( | |
if [ -d "$Fichero" ]; then | |
cd "$Fichero" | |
echo `pwd` | |
func_convertir | |
fi | |
) | |
if [ -f "$Fichero" ] | |
then | |
Extension=`echo $Fichero | gawk -F. '{print $2}'` | |
echo "Fichero es: $Fichero // Extension es: $Extension" | |
if [ $Extension = "jpg" ]; then | |
echo "`pwd`/$Fichero se va a optimizar..." | |
convert -quality 80% "$Fichero" "$Fichero" | |
fi | |
if [ $Extension = "JPG" ]; then | |
echo "`pwd`/$Fichero se va a optimizar..." | |
convert -quality 80% "$Fichero" "$Fichero" | |
fi | |
fi | |
done | |
} | |
func_convertir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment