-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkv-rm-cover
executable file
·49 lines (40 loc) · 944 Bytes
/
mkv-rm-cover
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
#!/bin/bash
set -eo pipefail
throw() {
printf '%s: %s\n' "${0##*/}" "$1" >&2
return 1
}
if [[ $1 =~ ^(--help|-h)$ ]]; then
cat >&2 <<'EOF'
Usage: mkv-rm-cover <path...>
Removes all image/jpeg and image/png attachments from the given MKVs.
See also: mkv-clean
Directories are expanded to contained *.mkv files (non-recursive). If no paths
are given, the current directory is used (equivalent to `mkv-rm-cover *.mkv`).
EOF
exit 1
fi
paths=()
paths_given=
while (( $# > 0 )); do
if [[ -d "$1" ]]; then
paths+=("$1"/*.mkv)
paths_given=1
else
paths+=("$1")
paths_given=1
fi
shift
done
if [[ ! $paths_given ]]; then
paths=(*.mkv)
fi
if (( ${#paths[@]} == 0 )); then
throw 'no files to process'
fi
for f in "${paths[@]}"; do
mkvpropedit "$f" \
--delete-attachment mime-type:image/jpeg \
--delete-attachment mime-type:image/png |
grep -v 'Warning: No attachment matched the spec' || true
done