CLI: replace one character in filenames recursively

I accidentally ran into a phenomenon that in a very big folder, I have so many files that has a character “·” and I need to remove it. At that time I have two options, either write a program my self or use existing command line tool to achieve my goal. At last I decided to use command line tool since it’s robust, well designed, commonly useful, efficient and time-saving.

All I need to know is find and rename, find tool is available on any UNIX and UNIX-like platforms, while rename is not available in Linux (AFAIC). So I used my LinuxMint to finish this task, very straightforward, here it goes:

find . -name “*.*” -exec rename ‘s/•//’ {} \;

I guess this “find . -name “xxx” {} \;” thing is just for recursive finding and “rename ‘s/•//'” did the trick of renaming.

Cool, CLI and Linux may make your life much easier. :-)

References:

01: http://blog.tordeu.com/?p=112

02: http://stackoverflow.com/questions/3279845/bash-recursively-copy-and-rename-files

Advertisements