-
Notifications
You must be signed in to change notification settings - Fork 6
/
meta-id3v2
executable file
·65 lines (63 loc) · 1.61 KB
/
meta-id3v2
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
#!/bin/bash
# This script aims to make batch audio tagging a little easier
function usage {
echo "Usage:"
echo " $ meta-id3v2 [ options ]"
echo "Options:"
echo " -r \"<regex>\" \"<other>\""
echo " Change the id3v2 title tags according to <regex> matching the entire filename,"
echo " which captures a group that is the intended name. Additionally, run <other> with id3v2."
echo " -t \"<regex>\" \"<other>\""
echo " Show the command(s) that will be run, were this given with -r"
echo " ***Don't trust that things weren't escaped right...escaping works better than it looks in the test..."
echo " -h"
echo " Display this usage message"
echo ""
echo "Example:"
echo " $ meta-id3v2 -t \"^..(.*)-.*$\" -A \"Cool Album Name\" -a \"Artist Name\""
echo " [confirm this ~= what you want]"
echo " $ meta-id3v2 -r \"^..(.*)-.*$\" -A \"Cool Album Name\" -a \"Artist Name\""
exit $1
}
opt=$1
if [ "$opt" == "-h" ]
then
usage 0
fi
regex=$2
shift
shift
extra=$@
if [ "$opt" == "-t" ]
then
for filename in ./*; do
if [ -f "$filename" ]
then
name=$filename
title=`echo $name | sed -E "s/$regex/\1/"`
echo id3v2 --song \"$title\" \"$filename\"
if [ X"$extra" != X ]
then
echo id3v2 "$extra" \"$filename\"
fi
fi
done
exit 0
fi
if [ "$opt" == "-r" ]
then
for filename in ./*; do
if [ -f "$filename" ]
then
name=$filename
title=`echo $name | sed -E "s/$regex/\1/"`
id3v2 --song "$title" "$filename"
if [ X"$extra" != X ]
then
id3v2 "$@" "$filename"
fi
fi
done
exit 0
fi
usage 1