How to rename multiple files using bash

So, I've had an issue recently, where I had a whole bunch of folders with some common part that I needed to remove. After searching on the internet I came across a website with the following script:

[bash]
#!/bin/bash
for item in *; do
newItem=`echo $item | sed 's/find/replace/g'`
mv "$item" "$newItem"
done
[/bash]

So, in my case, when I tried to remove a string 'str', I did the following:
[bash]
#!/bin/bash
for i in *; do
j=`echo $i | sed 's/str//g'`
mv "$i" "$j"
done
[/bash]

Original article could be found here: http://snipplr.com/view/2736/rename-multiple-files-in-bash-using-regular...

Comments