storing bits of the internet away for a rainy day

Bash Scripting: Mp3 Renaming

Posted by squirreling on May 11, 2008

Just wrote a quick script to rename a bunch of mp3 files, removing the site name from the file.  (ie from “23 Glory [www.site.com].mp3” to “23 Glory.mp3“.  This uses the ${var%remove-from-end} bash variable manipulation.

for file in *.mp3
       mv "$file" "${file%\[www.site.com\].mp3}.mp3"

See the Advanced Variable Manipulation in Mendel Cooper’s very useful Bash Scripting Guide.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: