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