{"id":195,"date":"2009-01-23T00:37:25","date_gmt":"2009-01-23T00:37:25","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2009\/01\/23\/bourne-file-name-converter\/"},"modified":"2021-08-01T11:16:07","modified_gmt":"2021-08-01T11:16:07","slug":"bourne-file-name-converter","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/bourne-file-name-converter.html","title":{"rendered":"Bourne – File name Converter"},"content":{"rendered":"
This script will convert any mp3\/wav\/wma files into neat and tidy naming format,<\/p>\n
#!\/bin\/sh<\/p>\n
ls | \/bin\/egrep -i “.wma|.mp3|.wav” > \/dev\/null
\nif [ $? == 0 ]<\/p>\n
then
\nls | \/bin\/egrep -i “.wma|.mp3|.wav”\u00a0 | while read source
\ndo
\ndest=$(echo “$source” | \/bin\/sed ‘s\/^[0-9]*[-,_]\/\/;s\/^-\/\/;s\/\\_\/ \/g;s\/^ *\/\/g;;s\/.*\/\\L&\/g;s\/-\/ – \/g;s\/\u00a0 \/ \/g;s\/\\<.\/\\u&\/g;s\/…$\/\\L&\/’)
\n\/bin\/mv -fv “$source” “$dest”
\ndone
\nexit 0
\nelse
\necho -e “\\E[31mERROR : No music files found in `pwd`”; tput sgr0
\nfi<\/p>\n
exit $?<\/p>\n
When copying this script to your UNIX terminal, please copy it into a text editor first. This will prevent any special characters being copied across with the script. A good tool to check this is to run cat -e filename.sh<\/strong> within your UNIX shell, this will show you the text and any special characters.<\/p>\n A modified script for the above can also be found below:<\/p>\n This script will convert any mp3\/wav\/wma files into neat and tidy naming format, #!\/bin\/sh ls | \/bin\/egrep -i “.wma|.mp3|.wav” > \/dev\/null if [ $? == 0 ] then ls | \/bin\/egrep -i “.wma|.mp3|.wav”\u00a0 | while read source do dest=$(echo “$source” | \/bin\/sed ‘s\/^[0-9]*[-,_]\/\/;s\/^-\/\/;s\/\\_\/ \/g;s\/^ *\/\/g;;s\/.*\/\\L&\/g;s\/-\/ – \/g;s\/\u00a0 \/ \/g;s\/\\<.\/\\u&\/g;s\/…$\/\\L&\/’) \/bin\/mv -fv “$source” “$dest” done exit … Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"yoast_head":"\n#!\/bin\/sh\r\n\r\nls | \/bin\/egrep -i \".wma|.mp3|.wav\" > \/dev\/null\r\nif [ $? == 0 ]\r\n\r\nthen\r\n ls | \/bin\/egrep -i \".wma|.mp3|.wav\" | while read source\r\n do\r\n dest=$(echo \"$source\" | \/bin\/sed 's\/^[0-9]*.[-,\"_\",\".\"]\/\/;s\/^-\/\/;s\/\\_\/ \/g;s\/^ \/\/g;;s\/.*\/\\L&\/g;s\/ \/ \/g;s\/\\<.\/\\u&\/g;s\/...$\/\\L&\/;s\/+\/ \/g;s\/([0-9]*)\/\/g;s\/^[0-3][0-9]\/\/g;s\/^ *\/\/g;s\/ [\".\"]\/.\/g;s\/--\\|- -\/-\/g;s\/[dD]on*e*l* \/Donnell \/g;s\/[dD].*.*n*gelo\/D`Angelo\/g;s\/[D][j]\/DJ\/g;s\/Ll [cC]ool\/LL Cool \/g;s\/-\/ - \/g;s\/ \/ \/g')\r\n \/bin\/mv -fv \"$source\" \"$dest\"\r\n done\r\n exit 0\r\nelse\r\n echo -e \"\\E[31mERROR : No music files found in `pwd`\"; tput sgr0\r\nfi\r\n\r\nexit $?\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"