shithub: img

ref: ab5412763ffb95ab14bbe642632e60661fab4aee
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