shithub: img

ref: 96efcddaa6c90f81e1e5ccaf6a49b35d935aec79
dir: /sdrip/rename.rc/

View raw version
#!/bin/rc -e

rename jpg JPG *.jpg >[2]/dev/null || {}
exiv2 --verbose --Force -t rename *.JPG *.HEIC

sha1sum *.JPG *.HEIC >[2]/dev/null | awk '
function quote(s){
	gsub("''", "''''", s)
	return sprintf("%s", s)
}
{
	hash=substr($1, 1, 8)
	date=substr($2, 1, 15)
	match($2, ".[A-Z]+$")
	fext=substr($2, RSTART+1, RLENGTH-1)
	printf "mv %s %s.%s.full.%s\n", quote($2), date, hash, fext
}' | rc