]> zdv2.bktei.com Git - BK-2020-03.git/blobdiff - user/bkfeh
chore(user/gthumb/prune.org):Minor fixes
[BK-2020-03.git] / user / bkfeh
index 7620e259f1b9cf5c336dee8b7512da1f9e31d6a0..e9f38fed0209dc3f75c5139288e267948927c8c7 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 # Desc: Wrapper for feh that accepts directory paths via posargs or stdin lines.
-# Version: 0.3.4
+# Version: 0.4.2
 # Ref/Attrib: [1] Tange, Ole. GNU Parallel with Bash Array. 2019-03-24. https://unix.stackexchange.com/a/508365/411854
 # Depends: GNU Parallel, GNU Bash v5.1.16, feh 3.6.3, GNU Coreutils 9.4 (b2sum, cp)
 
@@ -244,8 +244,23 @@ find_flist() {
     #        var: find_depth
     #        var: pattern_find_iregex
     #        var: find_size
-    if [[ ! -d "$1" ]]; then return 1; fi;
-    must find "$1" -maxdepth "$fdepth" -type f -iregex "$firegex" -size +"$fsize";
+    local din;
+
+    # Identify relevant directory containing files
+    if [[ -d "$1" ]]; then
+        ## Normal directory
+        din="$1";
+    elif [[ -h "$1" ]]; then
+        ## Symlink
+        din="$(readlink -f "$1"; )";
+        if [[ ! -d "$din" ]]; then
+            return 1;
+        fi;
+    else
+        return 1;
+    fi;
+
+    must find -L "$din" -maxdepth "$fdepth" -type f -iregex "$firegex" -size +"$fsize";
 }; # print file list to stdout from dir with script parameters
 save_sample() {
     # Usage: save_sample arg1
@@ -376,7 +391,7 @@ main() {
     
     # Generate file list
     # Find settings
-    firegex=".+\(jpg\|jpeg\|gif\|png\|webm\)$"; # update according to `find . -type f | grep -Eo "\.([[:alnum:]])+$" | sort -u`
+    firegex=".+\(jpg\|jpeg\|gif\|png\|webp\)$"; # update according to `find . -type f | grep -Eo "\.([[:alnum:]])+$" | sort -u`
     fsize="10k"; # default: minimum "10k"
     export firegex fsize ; # export for parallel
     ## Call find_filelist() in parallel for positional argument input
@@ -386,7 +401,7 @@ main() {
     fi;
     ## Call find_filelist() in parallel for stdin input
     if [[ "${#dirs_stdin[@]}" -gt 0 ]]; then
-        fdepth=1; export fdepth; # 1 ofr dirs from stdin
+        fdepth=1; export fdepth; # 1 for dirs from stdin
         paths_images+=("$( parallel find_flist {} "$fdepth" "$firegex" "$fsize" ::: "${dirs_stdin[@]}" )"); # See [1]
     fi;