How to rename many files and folders with Ant? For files I know I can do it like this; question
How to do the same thing for folders?
For e.g. Set of folders (Input)
com.google.appengine.eclipse.sdkbundle_1.5.2.r37v201107211953
com.google.gdt.eclipse.designer.doc.user_2.3.2.r37x201107161328
com.google.gdt.eclipse.designer.hosted.2_0.webkit_win32_2.3.2.r37x201107161253
org.eclipse.acceleo.common_3.1.0.v20110607-0602.jar
Output:
com.google.appengine.eclipse.sdkbundle_1.5.2
com.google.gdt.eclipse.designer.doc.user_2.3.2
com.google.gdt.eclipse.designer.hosted.2_0.webkit_win32_2.3.2
org.eclipse.acceleo.common_3.1.0.jar
This will move the directory and all of its sub-directories and files.
For complex operations I use the groovy ANT task.
The following example will rename your files and directories, using regular expressions:
NOTES:
Take a look at the Ant-Contrib tasks. One is the
<for>
task. This will allow you to specify multiple directories, directory patterns, etc. This way, you can loop through the directories and files.You can copy the files and directories to another location and use the Mapper to map the file names. (
<move>
task will also work with mappers.)I recommend you download the Ant-Contrib Jar file to the directory
${basedir}/antlib/ac
in your project. Then do this in the beginning of your build file:This will define the ant-contrib tasks and allow you to use them. If you're using a version control system and check everything in, someone can checkout your project and do a build without having to install Ant-Contrib first.