4

I would like to rename all of my java classes and layouts that starts with the prefix tranp_ to event_. I can do that one by one using the combination Shift+F6 but it is taking too much time (there are more than 20 files). Is there a quicker way to do that in bulk?

ajaysinghdav10d
  • 1,771
  • 3
  • 23
  • 33
  • 1
    does it have to be done within androidstudio? I believe it is pretty straightforward if you use the command line, like this example for bash: http://stackoverflow.com/a/602770/4511978 – fr_andres Oct 10 '16 at 08:26
  • 1
    Yes it has to be done in android studio because of the structure of the project ( the files names are used in the classes, layout and manifest) I need to maintain this structure. I used refractor so far. If there is another way to refractor it outside android-studio, please share your answer –  Oct 10 '16 at 08:30
  • I see... couldn't find anything neither. Maybe does androidstudio allow to update/incorporate the changes done with other tools? – fr_andres Oct 10 '16 at 08:39

3 Answers3

0

There seems to be no feature implemented to rename multiple files at once through refactoring provided within the Android Studio.

I also feel the need to have such feature as I keep changing my decision to name elements of certain category to some specific manner and thus have to tediously do it one by one. Which in many cases causes the bug.

I hope the future version will have it but till then what I am doing best at the moment is use the 'ctrl+r' feature to search all the occurrences of the item and replace it with what I want to rename to. And then do it again on all places where the element has been referenced. And then at last to make sure that there are no errors caused by the recent renaming I just run it. If any errors like "resources not found" then the Android Studio does point me to the location of the error, which generally is the place I left to rename.

Although this is not a sure way but it has helped me quite a lot when you have to rename lots of elements instead of 'shift+f6'.

NKoyee
  • 551
  • 6
  • 12
0

Although is an old question, I feel it's worth answering as there is a valid solution.

Open the project with AndroidStudio, then right click on the main project's folder, select "replace in path" and enjoy it. I just replaced 400 occurrences in less than 40 seconds, just make sure you really need to replace all statements!

0

So since I have tried the reply before me and it didn't help, I actually did find useful to open the direct path of the files I want to change, selected all of them and just pressed on rename(On MAC). It gave me the option to replace specific letters in all of the files. Made my life much easier after changing about 30 files, and noticing I have another 250 to change at least.

Dharman
  • 30,962
  • 25
  • 85
  • 135