the_earnest/dotfiles
improved findbooks script
Commit 8bfe5ed0989d · The Earnest · 2026-11-20 15:20 +0000
Comments
No comments yet.
Diff
diff --git a/scripts/findbook b/scripts/findbook
--- a/scripts/findbook
+++ b/scripts/findbook
@@ -4,16 +4,26 @@
SD=~/storage/sdcard
TMPFILE=$(mktemp)
-dir1="$SD/Books excluded/"
-dir2="$SD/Books/"
-dir3="$SD/Languages/"
+dirs=( \
+"$SD/Books excluded/" \
+"$SD/Books/" \
+"$SD/Languages/"
+)
+
+CMD='find '
-CMD='find "$dir1" "$dir2" "$dir3" -type f '
-if [[ $# -gt 0 ]]; then
+echo $THIS: searching these directories:
+for dir in "${dirs[@]}"; do
+ echo " $dir"|sed -e "s!$HOME!~!"
+ CMD+="'$dir' "
+done
+
+CMD+='-type f '
+if [[ $# -gt 0 ]] then
for searchterm in "$@"
do
CMD="$CMD -iname '*${searchterm}*' "
- echo $CMD
+ #echo $CMD
done
else
echo "$THIS: no arguments given, searching for all books"