开发者

One liner renaming a group of files and directories

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜