Skip to content

Commit 8be2c33

Browse files
author
Roel Kluin
committed
script update
1 parent 03f18c2 commit 8be2c33

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

tag_based_image_dedup.sh

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,14 @@
66
# you have to manually run remove_instructions.sh to remove the files
77
# this script requires exiftool and feh
88
# TODO: implement this in the extension
9+
#
10+
# Usage:
11+
# repo_dir=/path/to/repo
12+
# cd /path/to/images
13+
#
914

10-
ls -1 *.txt | while read f; do
11-
sed 's/, /\n/g' "$f" | sort | tr '\n' ',' | sed "s~,$~\t$f\n~"
12-
done | sort | awk -F'\t' '{
13-
a[$1] = a[$1] == "" ? $2 : a[$1]"\t"$2;
14-
} END {
15-
for (i in a) {
16-
if (index(a[i], "\t") != 0) {
17-
print a[i]"\t"i;
18-
}
19-
}
20-
}' > ../ff_dedup.txt
21-
22-
while read first_file second_file etc; do
15+
# use tabs as field separator
16+
while read -r -d '\t' first_file second_file etc; do
2317
# images may be jpg jpeg or png
2418
first_image=$(basename "$first_file" ".txt")
2519
if [[ -f "$first_image.jpg" ]]; then
@@ -80,7 +74,15 @@ while read first_file second_file etc; do
8074
echo rm "$first_file" "$first_image"
8175
fi
8276
kill $pid1 $pid2
83-
done < <(cat ../ff_dedup.txt) > remove_instructions.sh
84-
85-
86-
77+
done < <(
78+
ls -1 *.txt | while read f; do
79+
sed 's/, /\n/g' "$f" | sort | tr '\n' ',' | sed "s~,$~\t$f\n~"
80+
done | sort | awk -F'\t' '{
81+
a[$1] = a[$1] == "" ? $2 : a[$1]"\t"$2;
82+
} END {
83+
for (i in a) {
84+
if (index(a[i], "\t") != 0) {
85+
print a[i];
86+
}
87+
}
88+
}') > remove_instructions.sh

0 commit comments

Comments
 (0)