shithub: img

Download patch

ref: 483783068655c0cc4b7710008f8edc3a559e0479
parent: fa289cade26abe9c57986379d815b3a1316c93fa
author: Alex Musolino <musolinoa@gmail.com>
date: Sat Jun 3 13:07:25 EDT 2023

add support for HEIC ingestion and move images without exif data to "misc" album

--- a/sdrip/archive.rc
+++ b/sdrip/archive.rc
@@ -1,6 +1,10 @@
 #!/bin/rc
 
-{{ls *.JPG; ls *.HEIC} >[2]/dev/null} | awk -F_ '{
+{{ls *.JPG; ls *.PNG; ls *.HEIC} >[2]/dev/null} | awk -F_ '/^misc\./{
+	printf "mv -n %s %s/img/misc/%s\n", $0, ENVIRON["HOME"], $0
+	next
+}
+{
 	year=substr($1, 1, 4)
 	month=substr($1, 5, 2)
 	dirs[sprintf("%s/%s", year, month)] = 1
--- a/sdrip/rename.rc
+++ b/sdrip/rename.rc
@@ -1,17 +1,30 @@
 #!/bin/rc -e
 
+fn lscmd{
+	for(ext in HEIC JPG PNG)
+		ls *.^$ext >[2]/dev/null || {}
+}
+
 rename jpg JPG *.jpg >[2]/dev/null || {}
-exiv2 --verbose --Force -t rename `{{ls *.JPG; ls *.HEIC} >[2]/dev/null}
+rename png PNG *.PNG >[2]/dev/null || {}
+exiv2 -q --Force -t rename `{lscmd >[2]/dev/null} || true
 
-sha1sum `{{ls *.JPG; ls *.HEIC} >[2]/dev/null} | awk '
+sha1sum `{lscmd >[2]/dev/null} | awk '
 function quote(s){
 	gsub("''", "''''", s)
 	return sprintf("%s", s)
 }
-{
+/[0-9]{6}_[0-9]{6}\.[^.]*/{
 	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
+	next
+}
+{
+	hash=$1
+	match($2, ".[A-Z]+$")
+	fext=substr($2, RSTART+1, RLENGTH-1)
+	printf "mv %s misc.%s.full.%s\n", quote($2), $1, fext
 }' | rc