shithub: img

Download patch

ref: 3eed9609e23bd0c26e036a7fc48b9a81ea2a750a
parent: 483783068655c0cc4b7710008f8edc3a559e0479
author: Alex Musolino <alex@musolino.id.au>
date: Sat Aug 19 18:17:37 EDT 2023

add fns.rc to share lscmd between archive.rc and rename.rc

--- a/sdrip/archive.rc
+++ b/sdrip/archive.rc
@@ -1,6 +1,11 @@
 #!/bin/rc
 
-{{ls *.JPG; ls *.PNG; ls *.HEIC} >[2]/dev/null} | awk -F_ '/^misc\./{
+. ./fns.rc
+
+{lscmd >[2]/dev/null} | awk -F_ 'BEGIN{
+	dirs["misc"] = 1
+}
+/^misc\./{
 	printf "mv -n %s %s/img/misc/%s\n", $0, ENVIRON["HOME"], $0
 	next
 }
--- /dev/null
+++ b/sdrip/fns.rc
@@ -1,0 +1,6 @@
+#!/bin/rc
+
+fn lscmd{
+	for(ext in HEIC JPG PNG WEBP)
+		ls -- *.^$ext >[2]/dev/null || {}
+}
--- a/sdrip/rename.rc
+++ b/sdrip/rename.rc
@@ -1,9 +1,6 @@
 #!/bin/rc -e
 
-fn lscmd{
-	for(ext in HEIC JPG PNG)
-		ls *.^$ext >[2]/dev/null || {}
-}
+. ./fns.rc
 
 rename jpg JPG *.jpg >[2]/dev/null || {}
 rename png PNG *.PNG >[2]/dev/null || {}