开发者

One liner renaming a group of files and directories

开发者 https://www.devze.com 2023-03-01 22:05 出处:网络
I have a java project with the following naming convention {project-prefix}-{project type} such that we end up with:

I have a java project with the following naming convention {project-prefix}-{project type} such that we end up with:

  • files like prefix-type.xml, etc.
  • directories like com/organization/pr开发者_如何学编程efix-type/.
  • java files like /com/organization/prefix-type/PrefixFactory.java

I'm looking for a bash one liner that will rename the {project-prefix} portion of all of the files and directories in java project(*.java, *.xml, etc.) bonus points if it can handle the camel-case java files and/or extend the find/replace to the contents of the file


You can use the -exec option of find to execute a command in which you can use the name of the current matched file/directory (expanded with "{}"), something like:

find <directory> -iname <pattern> -exec mv "{}" $(modify {} whenever you want) \;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号