Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

globally replace text to rename multiple files in sublime

I'm working on a rails 4 app for which I need to change one of my model's names. This translates into changing a lot of other files such as the controller, view, etc.

I already generated a migration to change the table name. Then changed all owner to user inside all files within my app's directory using the global find and replace (i.e. ctrl+shift+F).

As a final step I only need to rename the file names as well for example the model from owner.rb to user.rb, owners_controller.rb to users_controller.rb, etc.

like image 881
jimbog Avatar asked Jan 26 '26 02:01

jimbog


1 Answers

If you are using a linux system instead of using sublime you could use a terminal, change directories to your project root and use:

find . -name '*owner*' -exec bash -c 'mv $0 ${0/owner/user}' {} \;

I found this technique here :), cheers

find a pattern in files and rename them

like image 98
TopGunCoder Avatar answered Jan 27 '26 19:01

TopGunCoder