View Single Post
Old 29th October 2009
DNAeon DNAeon is offline
Shell Scout
 
Join Date: Sep 2008
Location: Bulgaria
Posts: 138
Default

Hi,

How about using find to rename files? I've used this command to rename all .foo files to .bar

Code:
$ ls
1.foo  2.foo  3.foo
$ find . -type f -name "*.foo" -exec echo mv {} \`basename {} .foo\`.bar \;
mv ./1.foo `basename ./1.foo .foo`.bar
mv ./2.foo `basename ./2.foo .foo`.bar
mv ./3.foo `basename ./3.foo .foo`.bar
Then just feed it to the shell:
Code:
$ find . -type f -name "*.foo" -exec echo mv {} \`basename {} .foo\`.bar \; | sh
$ ls
1.bar  2.bar  3.bar
I think with a little modification and it can fit in any situation for renaming files.
__________________
"I never think of the future. It comes soon enough." - A.E

Useful links: FreeBSD Handbook | FreeBSD Developer's Handbook | The Porter's Handbook | PF User's Guide | unix-heaven.org
Reply With Quote