aboutsummaryrefslogtreecommitdiff
path: root/bin/tag-music
blob: 17d6aac512e25b643aedcf5398a1f4753f1a85a1 (plain)
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
#!/bin/sh

music_dir="$HOME/Music"

for artist_dir in "$music_dir"/*
do
    [ ! -d "$artist_dir" ] && continue
    artist="$(basename "$artist_dir")"
    [ "$artist" = backup ] && continue

    for album_dir in "$artist_dir"/*
    do
        album="$(basename "$album_dir")"
        [ ! -d "$album_dir" ] && continue

        for song_file in "$album_dir"/*
        do
            [ ! -f "$song_file" ] && continue
            song="$(basename "$song_file" | cut -d '.' -f 1)"
            # echo "$artist"
            # echo "$album"
            # echo "$song"
            case "$song_file" in
                *.ogg)
                    ;;
                *.opus)
                    echo "OPUS: $song_file"
                    echo "Title=$song
Artist=$artist
Album=$album
Track=
Total=
Date=
Genre=
Comment=" | opustags -i -S "$song_file"
                    ;;
                *.mp3)
                    id3tag --artist "$artist" --album "$album" --song "$song" "$songfile"
                    ;;
                *.m4a)
                    id3tag --artist "$artist" --album "$album" --song "$song" "$songfile"
                    ;;
                *)
                    ;;
            esac
        done
    done
done