ref: 743c38b176b1e9ce68d07a4e65d5d04ce5d29e8f
dir: /sdrip/rename.rc/
#!/bin/rc -e . ./fns.rc rename webp WEBP -- *.webp >[2]/dev/null || {} rename jpg JPG -- *.jpg >[2]/dev/null || {} rename png PNG -- *.png >[2]/dev/null || {} exiv2 -q --Force -t rename `{lscmd >[2]/dev/null} || true sha1sum -- `{lscmd >[2]/dev/null} | awk ' function quote(s){ gsub("''", "''''", s) return sprintf("%s", s) } /[0-9]{6}_[0-9]{6}\.[^.]*/{ hash=substr($1, 1, 8) date=substr($2, 1, 15) match($2, ".[A-Z]+$") fext=substr($2, RSTART+1, RLENGTH-1) src=quote($2) dst=sprintf("%s.%s.full.%s", date, hash, fext) if(src != dst) printf "mv -- %s %s\n", src, dst next } { hash=$1 match($2, ".[A-Z]+$") fext=substr($2, RSTART+1, RLENGTH-1) src=quote($2) dst=sprintf("misc.%s.full.%s", $1, fext) if(src != dst) printf "mv -- %s %s\n", src, dst }' | rc