批量重命名文件 - Android Studio

时间:2022-10-20 18:29:40

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?

我想重命名所有以前缀tranp_到event_开头的java类和布局。我可以使用Shift + F6组合逐个完成,但是花费了太多时间(有超过20个文件)。是否有更快的方式批量做到这一点?

1 个解决方案

#1


0  

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

似乎没有实现通过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.

我希望未来的版本能够拥有它,但在此之前,我目前做得最好的是使用'ctrl + r'功能来搜索项目的所有实例并将其替换为我想要重命名的内容。然后在所有引用元素的地方再次执行此操作。然后最后确保没有由最近重命名引起的错误我只是运行它。如果有任何错误,例如“找不到资源”,那么Android Studio确实会指出错误的位置,这通常是我要重命名的地方。

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'.

虽然这不是一个确定的方法,但是当你必须重命名很多元素而不是'shift + f6'时,它对我帮助很大。

#1


0  

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

似乎没有实现通过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.

我希望未来的版本能够拥有它,但在此之前,我目前做得最好的是使用'ctrl + r'功能来搜索项目的所有实例并将其替换为我想要重命名的内容。然后在所有引用元素的地方再次执行此操作。然后最后确保没有由最近重命名引起的错误我只是运行它。如果有任何错误,例如“找不到资源”,那么Android Studio确实会指出错误的位置,这通常是我要重命名的地方。

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'.

虽然这不是一个确定的方法,但是当你必须重命名很多元素而不是'shift + f6'时,它对我帮助很大。