From e415783fdf0ad1d6d83a98914df312b933de00ea Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Fri, 27 Dec 2019 19:00:58 -0500 Subject: [PATCH] Break-out video finder as independent script which also improves cleaning regexp --- home/bin/video-find | 11 +++++++++++ home/bin/video_catalog_update | 11 +---------- 2 files changed, 12 insertions(+), 10 deletions(-) create mode 100755 home/bin/video-find diff --git a/home/bin/video-find b/home/bin/video-find new file mode 100755 index 0000000..bf9fdc3 --- /dev/null +++ b/home/bin/video-find @@ -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}' diff --git a/home/bin/video_catalog_update b/home/bin/video_catalog_update index 8a1acc3..ea27e00 100755 --- a/home/bin/video_catalog_update +++ b/home/bin/video_catalog_update @@ -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" -- 2.20.1