shithub: img

ref: 074b6a4dfedeba87645fa0d30f4070e5481359f2
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