blob: 395a3f81b839ce6c8e5a73b29fb8abd5d110f372 (
plain) (
blame)
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
|
#!/bin/bash
# check for opustags
if [[ ! "$(command -v opustags)" ]]; then
printf "Opustags is required to run this script, please install\n"
exit 1
fi
# strip whitespace function
function _strip { awk '{gsub(/^[ \t]+| [ \t]+$/,""); print $0}' ; }
for i in *.opus; do
printf "Processing: %s... " "$i"
opustags -i -D "$i"
opustags -i -s "GENRE=Audiobook" "$i"
artist=$(printf "%s" "$i" | awk -F\- '{print $1}' | _strip)
opustags -i -s "ARTIST=$artist" "$i"
if [[ "$i" == *"#"* ]]; then
# series
album=$(printf "%s" "$i" | awk -F"-" '{print $2}' | awk -F"#" '{print $1}' | _strip)
track=$(printf "%s" "$i" | awk -F"-" '{print $2}' | awk -F"#" '{print $2}' | awk '{gsub ("^0*",""); print}' | _strip)
title=$(printf "%s" "$i" | awk -F"-" '{gsub(".opus",""); print $3}' | _strip)
opustags -i -s "ALBUM=$album" "$i"
opustags -i -s "TRACKNUMBER=$track" "$i"
opustags -i -s "TITLE=$title" "$i"
else
# single
title=$(printf "%s" "$i" | awk -F"-" '{gsub(".opus",""); print $2}' | _strip)
opustags -i -s "TITLE=$title" "$i"
fi
printf "Done.\n"
done
|