ref: e596cb983af53d3a18b484302b53ce8e0f8ec58f
dir: /sdrip/rename.rc/
#!/bin/rc flag e + . ./fns.rc rename webp WEBP -- *.webp >[2]/dev/null || {} rename jpg JPG -- *.jpg >[2]/dev/null || {} rename png PNG -- *.png >[2]/dev/null || {} files=`{lscmd >[2]/dev/null} if(~ $#files 0) exit 0 exiv2 -q --Force -t rename $files || {} 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