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'

Tuesday, December 19, 2006

Search and Replace Recursively with Bash

All one line!

find ./*.html -type f -exec sed - i 's/TextToReplace/ReplacementText/' {} \;