Skip to content

Instantly share code, notes, and snippets.

@rodrigo-x
Last active February 1, 2021 08:19
Show Gist options
  • Save rodrigo-x/e83f66a28db109d429ca97c974362a01 to your computer and use it in GitHub Desktop.
Save rodrigo-x/e83f66a28db109d429ca97c974362a01 to your computer and use it in GitHub Desktop.
Quebra-galho...
#!/usr/bin/env bash
MoveImg () {
clear
read -p "Digite o diretório das imagens Ex: /home/seuusuario/Imagens/ : " directory
checkDir () {
if [ ! -d "$directory" ]; then
clear
sleep 1
echo "Digite um diretório válido!"
exit 0
fi
}
checkDir
clear
read -p "Digite a resolução que quer filtrar as imagens Ex: 768*1366: " resols
checkResolution () {
if [ ! $(echo "$resols" | grep "^[0-9]") ]; then
clear
sleep 1
echo "Digite a resolução adequada com o * entre os números!"
exit 0
fi
}
checkResolution
moveToDir () {
for images in "$directory"*.jpg; do
resolution=$(identify -format "%h*%w" $images | cut -d : -f 1)
if [[ "$resolution" == "$resols" ]]; then
$(mv $images $HOME)
fi
done
}
moveToDir
}
MoveImg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment