shithub: img

ref: 2fa650c0e4cbbf0777eb10d91c0f4018cada9bb1
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