]> zdv2.bktei.com Git - BK-2020-03.git/blob - user/gthumb/rmall.org
feat(user/gthumb/keep.org):Add command to preserve selected files
[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.4
16 gThumb version: ~3.12.6~
17 Suggested keyboard shortcut: ~Shift + T~
18
19 ** Usage
20 *rmall* is useful for pruning photos with multiple format extensions
21 with each extension type in a separate directory. For example, letʼs
22 say a ~JPG/~ directory contains ~JPG/DSC01001.JPG~,
23 ~JPG/DSC01001.JPG.ots~ and a ~ARW/~ directory contains
24 ~ARW/DSC01001.ARW~. With ~JPG/DSC01001.JPG~ selected in gThumb, a
25 ~.trash~ directory is created next to ~JPG/~ and ~ARW/~. Then, the
26 following moves are performed:
27
28 - ~JPG/DSC01001.JPG~ is moved to ~.trash/JPG/DSC01001.JPG~
29 - ~JPG/DSC01001.JPG.ots~ is moved to ~.trash/JPG/DSC01001.JPG.ots~
30 - ~ARW/DSC01001.ARW~ is moved to ~.trash/ARW/DSC01001.ARW~
31
32 Thus, by browsing ~JPG/~ in gThumb and performing *rmall* on undesired
33 photos, the unwanted related photos from not only ~JPG/~, ~ARW/~ and
34 other similar directories are prepared for disposal in ~.trash~.
35
36 Then, it is upon the user to empty the contents of ~.trash~ to
37 permanently delete them.
38
39 ** Code
40 Line-by-line view:
41 #+BEGIN_EXAMPLE
42 # rmall v0.0.4
43 dbf=/tmp/gtlog.txt;
44 f="%F";
45 fBase="$(basename "$f")";
46 fne="${fBase%.*}";
47 dppar="$(dirname %P)";
48 dtrash="${dppar}/.trash";
49 printf "%s\n" "$dbf" "$f" "$fBase" "$fne" "$dppar" "$dtrash" 1>"$dbf" 2>&1;
50 for fsrc in "${dppar}/"*"/${fne}".*; do
51 if [ ! -e "$fsrc" ]; then continue; fi;
52 sdname="$(basename "$(dirname "$fsrc")")";
53 ddest="${dtrash}/${sdname}";
54 printf "fsrc:%s\n" "$fsrc";
55 printf "sdname:%s\n" "$sdname";
56 printf "ddest:%s\n" "$ddest";
57 if [ ! -d "$ddest" ]; then
58 printf "DEBUG:ddest does not exist:%s" "$ddest";
59 mkdir -p "$ddest";
60 else
61 printf "DEBUG:ddest exists:%s" "$ddest";
62 fi;
63 printf "STATUS: Moving %s → %s\n" "$fsrc" "$ddest/";
64 mv -n "$fsrc" "$ddest/";
65 done 1>>"$dbf" 2>&1;
66 sleep 1;
67 #+END_EXAMPLE
68
69 Paste-ready view:
70 #+begin_example
71 dbf=/tmp/gtlog.txt; f="%F"; fBase="$(basename "$f")"; fne="${fBase%.*}"; dppar="$(dirname %P)"; dtrash="${dppar}/.trash"; printf "%s\n" "$dbf" "$f" "$fBase" "$fne" "$dppar" "$dtrash" 1>"$dbf" 2>&1; for fsrc in "${dppar}/"*"/${fne}".*; do if [ ! -e "$fsrc" ]; then continue; fi; sdname="$(basename "$(dirname "$fsrc")")"; ddest="${dtrash}/${sdname}"; printf "fsrc:%s\n" "$fsrc"; printf "sdname:%s\n" "$sdname"; printf "ddest:%s\n" "$ddest"; if [ ! -d "$ddest" ]; then printf "DEBUG:ddest does not exist:%s" "$ddest"; mkdir -p "$ddest"; else printf "DEBUG:ddest exists:%s" "$ddest"; fi; printf "STATUS: Moving %s → %s\n" "$fsrc" "$ddest/"; mv -n "$fsrc" "$ddest/"; done 1>>"$dbf" 2>&1; sleep 1;
72 #+end_example