convert / resize lot of images

Created: Oct. 13, 2019, 7:45 p.m.
Update: March 31, 2020, 9:43 p.m.
convert lot of images

Environment

Linux Ubuntu
convert - https://packages.ubuntu.com/disco/graphicsmagick-imagemagick-compat
$ = line command

Convert lot of images in new folder

1 create a folder with name-800
2 convert all images of folder to 50% of original size.

Example

$ ls -la
drwxrwxr-x 2 user user 4096 Out 4 19:10 ci
drwxrwxr-x 2 user user 4096 Out 13 19:11 componentes-diversos
drwxrwxr-x 2 user user 4096 Jul 12 16:07 eletrica
drwxrwxr-x 2 user user 4096 Out 13 19:07 equipamentos-diversos
drwxrwxr-x 2 user user 4096 Jul 12 16:07 falantes-tv
drwxrwxr-x 2 user user 4096 Jul 12 18:59 ferro-solda-philips
drwxrwxr-x 2 user user 4096 Jul 12 16:10 galvanometro
drwxrwxr-x 2 user user 4096 Out 13 19:32 tape-deck-tampas
drwxrwxr-x 2 user user 4096 Out 13 19:32 walita-philips-engrenagem
drwxrwxr-x 3 user user 4096 Out 13 19:32 walita-philips-plastico-pecas-partes

set variables

$ SIZE='50%'
$ OUT='800'

Create folder name-800 and convert all images

convert all folders and files
$ for x in `ls`; do mkdir $x-$OUT; for xx in `ls $x`; do echo "+ $x/$xx"; convert -resize $SIZE $x/$xx $x-$OUT/$xx; done; done
convert selected folders
$ for x in equipamentos-diversos componentes-diversos;
do mkdir $x-$OUT; for xx in `ls $x`; do echo "+ $x/$xx"; convert -resize $SIZE $x/$xx $x-$OUT/$xx; done; done
output 
drwxrwxr-x  2 user user    4096 Out  4 19:10 ci
drwxrwxr-x  2 user user    4096 Out  4 19:10 ci-800
drwxrwxr-x  2 user user    4096 Out 13 19:11 componentes-diversos
drwxrwxr-x  2 user user    4096 Out 13 19:11 componentes-diversos-800
drwxrwxr-x  2 user user    4096 Jul 12 16:07 eletrica
drwxrwxr-x  2 user user    4096 Jul 12 16:07 eletrica-800
drwxrwxr-x  2 user user    4096 Out 13 19:07 equipamentos-diversos
drwxrwxr-x  2 user user    4096 Out 13 19:07 equipamentos-diversos-800
...

Delete folder that contain 800 at end of name and all content.

find . -name '*800' -exec rm -rf '{}' \;

Tiago de Souza Moraes - teago.futuria.com.br - 2020 // CSS by UIKIT CSS