summaryrefslogtreecommitdiff
path: root/bin/menuscripts/muzrname
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-06-01 13:32:36 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-06-01 13:34:53 +0200
commit82d07da3add2393c53d20e41e8aba383f058858f (patch)
tree20e62d7b1cc5428703f1cde9500efa54c52daf50 /bin/menuscripts/muzrname
parentcf01ac4c10ecd0cdffed722fd58301ebfddd0d61 (diff)
checkpoint
Diffstat (limited to 'bin/menuscripts/muzrname')
-rwxr-xr-xbin/menuscripts/muzrname22
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/menuscripts/muzrname b/bin/menuscripts/muzrname
new file mode 100755
index 0000000..3f63aff
--- /dev/null
+++ b/bin/menuscripts/muzrname
@@ -0,0 +1,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