[download]

local/bin/imrename

   1 #!/bin/bash
   2 
   3 [[ $1 == -e || $1 == --exif ]] &&
   4 shift && exiv2 -vFtr '%F %T' "$@"
   5 
   6 [[ $1 == -h || $1 == --hash ]] &&
   7 shift && md5sum "$@" | while read sum file; do
   8     mv -vn "$file" ${sum:0:6}.${file##*.}
   9 done
  10 
  11 [[ $1 == -m || $1 == --meta ]] &&
  12 shift && for file in "$@"; do
  13     r=$(identify -format '%wx%h' "$file" 2>&-)
  14     c=$(convert "$file" -scale 5% -colors 1 -unique-colors txt: |
  15     awk -F '[# ]+' 'NR > 1 { print substr($3, 0, 6) }' | paste -sd -)
  16     mv -vn "$file" $c-$r.${file##*.}
  17 done