Skip to content

Commit c2e63ec

Browse files
committed
Use feh instead of sxiv for diffpic.
1 parent b5df35d commit c2e63ec

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

diffpic

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,20 @@
11
#!/bin/bash
2-
# This script helps find duplicate photos and delete the ones that have the
3-
# (subjective) worst quality. We use `findimagedupes` to find visual
4-
# duplicates. Note that it might be useful to first use `fdupes` to find binary
5-
# duplicates. Once duplicates are found, they are displayed with `sxiv`. In
6-
# sxiv, mark files with `m` to move them to trash, then quit with `q` for the
7-
# next batch.
8-
# Dependencies: findimagedupes exif sxiv
2+
# This script helps find duplicate photos in a directory, and delete the ones
3+
# that have the (subjective) worst quality.
4+
#
5+
# 1. We first use `fdupes` to find binary duplicates.
6+
# 2. Then we use `findimagedupes` to find visual duplicates. Those duplicates are
7+
# shown with `feh` in batches, allowing you to use Ctrl+Del to delete the ones
8+
# you don't like.
9+
# Dependencies: `findimagedupes` `fdupes` `feh` (`zenity`, `xargs` for renaming)
910
set -euo pipefail
1011

11-
# Prepare script for displaying additional image info in sxiv, if no such
12-
# script exists yet (still a bit invasive, you might not want this)
13-
INFODIR="$(xdg-user-dir CONFIG)/sxiv/exec"
14-
INFO="${INFODIR}/image-info"
15-
if [ ! -f "${INFO}" ]; then
16-
mkdir -p ${INFODIR}
17-
tee "${INFO}" 1> /dev/null << EOF
18-
#!/bin/bash
19-
F="\$1"
20-
WIDTH="\$2"
21-
HEIGHT="\$3"
22-
SIZE="\$(ls -lh "\$F" | cut -d' ' -f5)"
23-
TIME="\$(exif --machine-readable --tag=DateTime "\$F" 2> /dev/null || echo "!EXIF")"
24-
MODIFIED="(mod. \$(date -r "\$F" '+%Y-%m-%d'))"
25-
NAME="\$(basename "\$F")"
26-
echo \${NAME} \${WIDTH}x\${HEIGHT} \${SIZE} \${TIME} \${MODIFIED}
27-
EOF
28-
chmod +x "${INFO}"
29-
fi
12+
DIR=${1:-${PWD}}
13+
14+
echo "Finding binary duplicates..." >&2
15+
fdupes --delete --noempty --time --size "${DIR}"
16+
17+
echo "Finding visual duplicates..." >&2
3018

3119
# Prepare temporary directory and make sure it will be removed afterward
3220
TMP=$(mktemp -d "${TMPDIR:-/tmp}/$(basename "$0").XXXXX")
@@ -38,12 +26,24 @@ trap finalize EXIT
3826
# Prepare script for viewing & subsequent removal of duplicates
3927
tee "${TMP}/custom.sh" 1> /dev/null << EOF
4028
VIEW(){
41-
sxiv "\$@" -o \
42-
| xargs -I{} gio trash {}
29+
feh \
30+
--borderless \
31+
--auto-rotate \
32+
--scale-down \
33+
--zoom fill \
34+
--draw-tinted \
35+
--draw-actions \
36+
--draw-filename \
37+
--caption-path "." \
38+
--sort filename \
39+
--info "exiv2 %F | grep -v ':\s*$'; echo Size: %w×%h - %Sb; echo -n Modification:; date -r %F '+%%Y-%%m-%%d %%R'" \
40+
--edit \
41+
--action1 '[rename]zenity --entry --text "Rename:" --entry-text %F | xargs mv %F' \
42+
--action9 '[remove]zenity --question && gio trash %F' \
43+
"\$@"
44+
exit 0
4345
}
4446
EOF
45-
46-
# Find duplicates in current directory and execute script
4747
find "${DIR:-.}" -mindepth 1 -maxdepth 1 -regex '.*\.\(png\|jpg\|jpeg\|tiff\|bmp\)' |
4848
findimagedupes --script="${TMP}/script.sh" --include-file="${TMP}/custom.sh" -
4949
sh ${TMP}/script.sh

0 commit comments

Comments
 (0)