Skip to content

Instantly share code, notes, and snippets.

@mikedigriz
Created January 3, 2024 15:17
Show Gist options
  • Save mikedigriz/1055ba7436b1c553daaa31bf01040476 to your computer and use it in GitHub Desktop.
Save mikedigriz/1055ba7436b1c553daaa31bf01040476 to your computer and use it in GitHub Desktop.
move images with width less than 1600, or 1080p to dir
##
# move 1080p images to folder
# read first script (move_low_res_img.sh) for fix issues
##
#!/bin/bash
shopt -s nullglob
for fname in *.jpg *.png *.gif
do
read width height < <(exiv2 "$fname" 2>&1 | awk '/^Размер изображения/{print $3,$5}')
[ "$width" ] || continue
[ "$width" -eq 1920 ] && [ "$height" -eq 1080 ] && mv "$fname" /home/yourdir/1080p
done
##
# apt-get install exiv2
# in Russian lang exiv2 output: Image size = Размер изображения
# check output for your file: exiv2 image.jpg 2>&1 | awk '/^Размер изображения/{print $3,$5}'
##
#!/bin/bash
shopt -s nullglob
for fname in *.jpg *.png *.gif
do
read width height < <(exiv2 "$fname" 2>&1 | awk '/^Размер изображения/{print $3,$5}')
[ "$width" ] || continue
[ "$width" -lt 1600 ] && mv "$fname" /home/yourdir/bad/
done
@mikedigriz
Copy link
Author

for rename files in dir to 1.jpg, 2.png, 3.jpg see

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment