File: scan

package info (click to toggle)
xwax 0.7-5
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 312 kB
  • ctags: 524
  • sloc: ansic: 3,921; makefile: 104; sh: 101
file content (32 lines) | stat: -rwxr-xr-x 789 bytes parent folder | download
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/sh
#
# Take a pathname as an argument and output a playlist to standard
# output and errors to standard error.
#
# The output format is repeated sequences of:
#
#   <pathname>\t<artist>\t<title>\n
#
# If the tab (\t) or newline (\n) characters appear in a filename,
# unexpected things will happen.

PATHNAME="$1"

if [ -d "$PATHNAME" ]; then
	find -L "$PATHNAME" -type f
else
	cat "$PATHNAME"
fi | sed -n '
{
# /[<num>[.]] <artist> - <title>.ext
s:/\([0-9]\+.\? \+\)\?\([^/]*\) \+- \+\([^/]*\)\.[a-zA-Z0-9]*$:\0\t\2\t\3:p
t

# /<artist> - <album>[/Disc <n>.*]/[<num>[.]] <title>.ext
s:/\([^/]*\) \+- \+\([^/]*\)\(/Disc [0-9][^/]*\)\?/\([0-9]\+.\? \+\)\?\([^/]*\)\.[a-zA-Z0-9]*$:\0\t\1\t\5:p
t

# /[<num>[.]] <name>.ext
s:/\([0-9]\+.\? \+\)\?\([^/]*\)\.[a-zA-Z0-9]*$:\0\t\t\2:p
}
'