Here's an example script I used to refactor the names of files in a C project.
It can easily be adapted to refactor variable names, etc in JavaScript, Ruby, Python, PHP (*shudder*), etc.


if [ ! -n "${1}" ]
    echo "
Usage: new_basename old_basename

Note: do not include '.c' or '.h', this is added for you.


svn mv include/${OLD}.h include/${NEW}.h
svn mv ${OLD}.c ${NEW}.c

find ./ -name '*.c' | xargs sed -i "s/${OLD}\.h/${NEW}\.h/gi"
find ./ -name '*.c' | xargs sed -i "s/${OLD}\.c/${NEW}\.c/gi"

find ./ -name '*.h' | xargs sed -i "s/${OLD}\.h/${NEW}\.h/gi"
find ./ -name '*.h' | xargs sed -i "s/${OLD}\.c/${NEW}\.c/gi"

By AJ ONeal

If you loved this and want more like it, sign up!

Did I make your day?
Buy me a coffeeBuy me a coffee  

(you can learn about the bigger picture I'm working towards on my patreon page )