summaryrefslogtreecommitdiff
path: root/bin/menuscripts/muzrname
blob: 3f63aff4cc9d9f04d8db3967eb701cd83e7fc73b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh

rename()
{
	## Expression 1:
	# For CDs or volumes 1-01 -> 1_01
	## Expression 2:
	# * don't match the start (^)
	# match the first part with a number and replace following [ -.] by '. '
	sed -e 's/^\s*\([0-9]\+\)[ -_.]\([0-9]\+\)/\1_\2. /' \
		-e 's#\s*\([0-9]\+\)[ -.]\+#\1. #'
}

if [ ! -t 0 ]
then 
	rename
elif [ "$1" ]
then 
	printf '%s' "$1" | rename
else
	exit 1
fi