File: dr_file2tag

package info (click to toggle)
draai 20201215-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 656 kB
  • sloc: sh: 854; perl: 170; makefile: 28
file content (39 lines) | stat: -rwxr-xr-x 708 bytes parent folder | download | duplicates (8)
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
#!/bin/sh

# This file is maintained at http://git.mdcc.cx/draai
#
# Copyright: © 2008 Joost van Baal. This program is in the public domain.

# dr_file2tag - build tag info from filename
#
# example usage:
#   eval `dr_file2tag 03-Wochtzchée-Sleepin_instructions_\(extract\).ogg`
#

set -e

file="$1"
# [artist-]title.{ogg,mp3}

# strip .mp3 , .ogg
file="`echo $file | sed 's/\.[^\.]*$//'`"

# strip leading 01-
file="`echo $file | sed 's/^[0-9]*-//'`"

file="`echo $file | sed 's/_/ /g'`"

artist="`echo $file | cut -d- -f1`"

if test "$artist" != "$file"
then
    echo "ARTIST=$artist"
    file="`echo $file | cut -d- -f2`"
fi

echo "TITLE=$file"

# oggenc(1):
# ARTIST is -a, ALBUM is -l TITLE is -t.