shithub: img

ref: fa289cade26abe9c57986379d815b3a1316c93fa
dir: /sdrip/rename.rc/

View raw version
#!/bin/rc -e

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

sha1sum `{{ls *.JPG; ls *.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