Break-out video finder as independent script
authorSiraaj Khandkar <siraaj@khandkar.net>
Sat, 28 Dec 2019 00:00:58 +0000 (19:00 -0500)
committerSiraaj Khandkar <siraaj@khandkar.net>
Sat, 28 Dec 2019 00:00:58 +0000 (19:00 -0500)
which also improves cleaning regexp

home/bin/video-find [new file with mode: 0755]
home/bin/video_catalog_update

diff --git a/home/bin/video-find b/home/bin/video-find
new file mode 100755 (executable)
index 0000000..bf9fdc3
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+find $@ \
+    -type f \
+    -print0 \
+| xargs \
+    -0 \
+    -P "$(nproc)" \
+    -I {} \
+    sh -c 'printf "%s\0%s\0\0" $(mimetype -b "{}") "{}"' \
+| gawk -v RS='\0\0' -v ORS='\0' '/^video/ {sub("^[^\0]+\0", ""); print}'
index 8a1acc3..ea27e00 100755 (executable)
@@ -2,13 +2,4 @@
 
 set -e
 
-find "$DIR_VIDEO" \
-    -type f \
-    -print0 \
-| xargs \
-    -0 \
-    -P "$(nproc)" \
-    -I{} \
-    sh -c 'printf "%s %s\n" $(mimetype -b "{}") "{}"' \
-| awk '/^video/ {sub($1 " +", ""); print}' \
-> "$FILE_VIDEO_CATALOG"
+video-find "$DIR_VIDEO" | xargs -0 -I% echo % > "$FILE_VIDEO_CATALOG"
This page took 0.041234 seconds and 4 git commands to generate.