Wednesday, December 20, 2006

Recursively rename files with regex (one-liner)

Change 'foo' to 'bar' in all filenames under the current directory

To Preview Your Changes


find . -type f -print0 | xargs -0 rename -n 's/foo/bar/g'


To do the actual rename

find . -type f -print0 | xargs -0 rename 's/foo/bar/g'

2 comments:

Brad said...

Super Awesome! One-liners are good!

梦中林 said...

When the Wow Gold wolf finally found the wow gold cheap hole in the chimney he crawled cheap wow gold down and KERSPLASH right into that kettle of water and that was cheapest wow gold the end of his troubles with the big bad wolf.

The next day the Buy Wow Goldlittle pig invited hisbuy gold wow mother over . She said "You see it is just as mygamegoldI told you. The way to get along in the world is to do world of warcraft gold things as well as you can." Fortunately for that little pig, he buy cheap wow gold learned that lesson. And he just k4gold lived happily ever after!