Ive recently written a small script, to reformat the titles of my music files.
The script creates a new filename and then moves the file...
#!/bin/sh
/bin/ls | /bin/egrep -i ".wma|.mp3|.wav" > /dev/null
if [ $? == 0 ]
then
do
for s in `ls | egrep -i ".wma|.mp3|.wav" ` ;
do
dest=$(echo $s | sed 's/^[0-9]*//;s/^-//;s/\_/ /g;s/-/ - /g') ;
/bin/mv -fv $s $dest
done
exit 0
else
echo -e '\E[31mERROR : No music files found'; tput sgr0
exit 1
fi
exit $?
To test the script on just a text file of my file names I have created the following,
#!/bin/sh
cat test.txt | egrep -i ".wma|.mp3|.wav" > /dev/null
if [ $? == 0 ]
then
for s in `cat test.txt | egrep -i ".wma|.mp3|.wav" ` ;
do
dest=$(echo $s | sed 's/^[0-9]*//;s/^-//;s/\_/ /g;s/-/ - /g') ;
echo $dest
done
exit 0
else
echo -e '\E[31mERROR : No music files found'; tput sgr0
exit 1
fi
exit $?
The problem is, is that the output is printing out the blank spaces as new lines, which i presume is down to how the for loop/sed is inputing and outing the text.
Can anyone help ??
The script creates a new filename and then moves the file...
#!/bin/sh
/bin/ls | /bin/egrep -i ".wma|.mp3|.wav" > /dev/null
if [ $? == 0 ]
then
do
for s in `ls | egrep -i ".wma|.mp3|.wav" ` ;
do
dest=$(echo $s | sed 's/^[0-9]*//;s/^-//;s/\_/ /g;s/-/ - /g') ;
/bin/mv -fv $s $dest
done
exit 0
else
echo -e '\E[31mERROR : No music files found'; tput sgr0
exit 1
fi
exit $?
To test the script on just a text file of my file names I have created the following,
#!/bin/sh
cat test.txt | egrep -i ".wma|.mp3|.wav" > /dev/null
if [ $? == 0 ]
then
for s in `cat test.txt | egrep -i ".wma|.mp3|.wav" ` ;
do
dest=$(echo $s | sed 's/^[0-9]*//;s/^-//;s/\_/ /g;s/-/ - /g') ;
echo $dest
done
exit 0
else
echo -e '\E[31mERROR : No music files found'; tput sgr0
exit 1
fi
exit $?
The problem is, is that the output is printing out the blank spaces as new lines, which i presume is down to how the for loop/sed is inputing and outing the text.
Can anyone help ??