abcde-l1.mp3 abcde-l2.mp3 abcde-l3.mp3 abcde.meta.xml abcde.wav
We want to rename them to
12345-l1.mp3 12345-l2.mp3 12345-l3.mp3 12345.meta.xml 12345.wav
#!/bin/bash
if [[ ! $1 ]]; then
echo "No argument supplied"
exit 1
fi
newname=$1
for entry in /Users/msun/msun/sound/*.wav; do
#Get file name without path e.g. abc.wav
filename=$(basename $entry)
#Get file name without extension e.g. abc
filename="${filename%.*}"
break
done
#replace $filename with $newname
for entry in /Users/msun/msun/sound/*; do
mv $entry ${entry/$filename/$newname}
done