]> zdv2.bktei.com Git - BK-2020-03.git/blob - user/gthumb/rmall.org
chore(unitproc/bkt-sum_float):Add author and license
[BK-2020-03.git] / user / gthumb / rmall.org
1 #+AUTHOR: Steven Baltakatei Sandoval
2 #+DATE: 2026-06-16
3 #+TITLE: rmall
4
5 ** Summary
6 This command moves to trash a single selected file ~dir1/file123.ext~
7 along with any adjacent files that share the same stem located within
8 the same directory (e.g. ~dir1/file123.*~). Also moved are matching
9 files in directories neighboring the originalʼs parent directory
10 (e.g. ~dir2/file123.*~). The destination trash directory is ~.trash~;
11 parent directories (e.g. ~dir1~, ~dir2~) are preserved within
12 ~.trash/~.
13
14 ** Stats
15 Version: 0.0.6
16 License: GPLv3+
17 gThumb version: ~3.12.6~
18 Suggested keyboard shortcut: ~Shift + T~
19
20 ** Usage
21 *rmall* is useful for pruning photos with multiple format extensions
22 with each extension type in a separate directory. For example, letʼs
23 say a ~JPG/~ directory contains ~JPG/DSC01001.JPG~,
24 ~JPG/DSC01001.JPG.ots~ and a ~ARW/~ directory contains
25 ~ARW/DSC01001.ARW~. With ~JPG/DSC01001.JPG~ selected in gThumb, a
26 ~.trash~ directory is created next to ~JPG/~ and ~ARW/~. Then, the
27 following moves are performed:
28
29 - ~JPG/DSC01001.JPG~ is moved to ~.trash/JPG/DSC01001.JPG~
30 - ~JPG/DSC01001.JPG.ots~ is moved to ~.trash/JPG/DSC01001.JPG.ots~
31 - ~ARW/DSC01001.ARW~ is moved to ~.trash/ARW/DSC01001.ARW~
32
33 Thus, by browsing ~JPG/~ in gThumb and performing *rmall* on undesired
34 photos, the unwanted related photos from not only ~JPG/~, ~ARW/~ and
35 other similar directories are prepared for disposal in ~.trash~.
36
37 Then, it is upon the user to empty the contents of ~.trash~ to
38 permanently delete them.
39
40 ** Code
41 Paste the code below into the ~Command~ field of the ~Edit Command~
42 window under 🔧 → Personalize… .
43
44 Line-by-line view:
45 #+BEGIN_EXAMPLE
46 # rmall v0.0.6
47 fdebug=/tmp/gtlog.txt;
48 f=%F;
49 fBase="$(basename "$f")";
50 fne="${fBase%.*}";
51 dppar="$(dirname %P)";
52 dtrash="${dppar}/.trash";
53 if [ -z "$fne" ]; then printf "FATAL: Empty stem from:%s\n" "$fne" 1>>"$fdebug" 2>&1; exit 1; fi;
54 runDate="$(date -Is 2>&1)";
55 printf "STATUS:runDate:%s\n" "$runDate" 1>>"$fdebug" 2>&1;
56 printf "DEBUG:fdebug:%s\n" "$fdebug" 1>>"$fdebug" 2>&1;
57 printf "DEBUG:f:%s\n" "$f" 1>>"$fdebug" 2>&1;
58 printf "DEBUG:fBase:%s\n" "$fBase" 1>>"$fdebug" 2>&1;
59 printf "DEBUG:fne:%s\n" "$fne" 1>>"$fdebug" 2>&1;
60 printf "DEBUG:dppar:%s\n" "$dppar" 1>>"$fdebug" 2>&1;
61 printf "DEBUG:dtrash:%s\n" "$dtrash" 1>>"$fdebug" 2>&1;
62 for fsrc in "${dppar}"/*/"${fne}".*; do
63 if [ ! -e "$fsrc" ]; then continue; fi;
64 sdname="$(basename "$(dirname "$fsrc")")";
65 ddest="${dtrash}/${sdname}";
66 printf "DEBUG:fsrc:%s\n" "$fsrc" 1>>"$fdebug" 2>&1;
67 printf "DEBUG:sdname:%s\n" "$sdname" 1>>"$fdebug" 2>&1;
68 printf "DEBUG:ddest:%s\n" "$ddest" 1>>"$fdebug" 2>&1;
69 if [ ! -d "$ddest" ]; then
70 printf "DEBUG:Destination dir does not exist. Creating:%s\n" "$ddest" 1>>"$fdebug" 2>&1;
71 mkdir -p "$ddest";
72 else
73 printf "DEBUG:Destination dir exists:%s\n" "$ddest" 1>>"$fdebug" 2>&1;
74 fi;
75 printf "STATUS: Moving %s → %s\n" "$fsrc" "$ddest/" 1>>"$fdebug" 2>&1;
76 mv -n "$fsrc" "$ddest/";
77 done 1>>"$fdebug" 2>&1;
78 sleep 1;
79 #+END_EXAMPLE