Actually i am using <move>
cmd for renaming one folder instead of <rename>
cmd. but in my case i am moving here 48746 files, so takes 1 approx hour. pls tell me ant appropriate way to rename that folder in optimal way. Thanks in advance.
<target name="rename_folder_jet" depends="Upload_on_ftp">
<move todir="${build.dir}_jet_${ver_number}">
<fileset dir="${build.dir}">
<include name="**/*.*"/>
</fileset>
</move>
</target>
Try to move/rename the directory only, rather than all its contents. Like this:
<target name="rename_folder_jet" depends="Upload_on_ftp">
<move file="${build.dir}" todir="${build.dir}_jet_${ver_number}"/>
</target>
And make sure that the target directory does not exist before you start.
I experimented with the following build file:
<project default="rename_folder_jet">
<property name="build.dir" value="build"/>
<property name="ver_number" value="0.3"/>
<target name="setup">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.dir}/foo"/>
<mkdir dir="${build.dir}/bar"/>
</target>
<target name="teardown">
<delete dir="${build.dir}_jet_${ver_number}"/>
</target>
<target name="rename_folder_jet">
<move file="${build.dir}" todir="${build.dir}_jet_${ver_number}"/>
</target>
</project>
Executing Ant in debug (ant -d) with the above is interesting.
Case 1:
ant teardown
ant setup
ant -d
In this case, the target directory of the move/rename does not exist. The debug output of Ant shows:
[move] Attempting to rename dir: C:\Users\sudocode\tmp\ant\build to C:\Users\sudocode\tmp\ant\build_jet_0.3\build
Case 2:
ant setup
ant
ant setup
ant -d
In this case, the target directory exists already on the second execution. The debug output of Ant shows:
[move] Attempting to rename dir: C:\Users\sudocode\tmp\ant\build to C:\Users\sudocode\tmp\ant\build_jet_0.3\build
fileset: Setup scanner in dir C:\Users\sudocode\tmp\ant\build with patternSet{ includes: [] excludes: [] }
[move] Deleting directory C:\Users\sudocode\tmp\ant\build\foo
[move] Deleting directory C:\Users\sudocode\tmp\ant\build\bar
[move] Deleting directory C:\Users\sudocode\tmp\ant\build
So it seems that if the target directory does not already exist, Ant will do a rename of the directory. But if the target directory exists, it instead does a copy into the directory and delete from the source directory instead.