Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 119cb0d962
Fetching contributors…

Cannot retrieve contributors at this time

executable file 30 lines (22 sloc) 0.736 kb
#!/bin/bash
if ! type -P identify >/dev/null; then
echo "identify not found -- missing imagemagick?"
exit 1
fi
wallpaper_root="$HOME/pic/wallpaper"
while read -r -d '' pic; do
read -r width height < <(identify '%w %h' "$pic")
case $(echo "scale=3;$width / $height" | bc) in
1.777) ratio='16:9' ;;
1.600) ratio='16:10' ;;
1.333) ratio='4:3' ;;
1.250) ratio='5:4' ;;
*) ratio='other'
printf -v prefix '%sx%x_' "$width" "$height" ;;
esac
if [[ $ratio && ! -d $wallpaper_root/$ratio/$widthx$height ]]; then
mkdir -vp "$wallpaper_root/$ratio/${width}x$height"
fi
mv -v "$pic" "$wallpaper_root/$ratio/$prefix${pic##*/}"
unset prefix
done < <(find "${1:-.}" -maxdepth 1 -type f -print0)
Jump to Line
Something went wrong with that request. Please try again.