-
Notifications
You must be signed in to change notification settings - Fork 0
/
lsvdups
executable file
·66 lines (46 loc) · 1.66 KB
/
lsvdups
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
set -eu
# Really dumb video duplicate finder.
# Can detect same videos in different formats/quality, WILL NOT detect
# different cuts of the same video, because it essentially only compares
# thumbnails.
# By default only compares for mp4, webm and mkv.
# Look for "FORMATS" below to change that.
# USAGE:
# 1. lsvdups /some/dir/with/videos
# 2. sxiv will open
# 3. mark (m) thumbnails of videos you want to delete
# depends on:
# lsidups (obviously)
# sortsize (from examples)
# fd - https://github.com/sharkdp/fd
# ffmpegthumbnailer - https://github.com/dirkvdb/ffmpegthumbnailer
# xargs from findutils (probably already installed)
# path to directory with videos
videos="$(realpath "$1")"
# list of its inner directory structure
dirs=/tmp/lsvdups.dirs.txt
# where to map this structure
img=/tmp/image
# get directory structure
(echo $PWD; fd -t d . "$videos") | sed "s|^/||g" > $dirs
# clean up
rm -rf $img.{dups,del} $img
mkdir -p $img
cd $img
# copy directory structure
xargs -d '\n' -I{} -n1 -r mkdir -p "{}" < $dirs
# FORMATS: map inside it videos via thumbnails
fd -t f -e webm -e mp4 -e mkv . "$videos" -x ffmpegthumbnailer -s 0 -i {} -o "$img/{}.jpeg"
# find duplicate and sort with biggest (usually largest resolution) first
lsidups -v -i $img -j | sortsize > $img.dups
[ $(wc -l < $img.dups) = 0 ] && exit 0
echo 'mark thumbnails of videos you want to delete with m'
# show duplicates
sxiv -io < $img.dups > $img.del
# delete marker (does not run if list is empty)
sed "s|\.jpeg$||g;s|$img||g" $img.del | while read -r vid; do
echo "rm $vid"
rm "$vid"
# or use trash-put from https://github.com/andreafrancia/trash-cli
done