重命名VS移动Ant任务 [英] Rename Vs Move Ant task

查看:220
本文介绍了重命名VS移动Ant任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其实我使用<移动> CMD重命名一个文件夹,而不是<重命名> CMD。但在我的情况下,我在这里移动48746的文件,所以需要1小时左右。请告诉我蚂蚁适当的方式到该文件夹​​重命名最佳方式。先谢谢了。

 <目标名称=rename_folder_jet取决于=Upload_on_ftp>
    <将todir =$ {} build.dir _ _jet $ {} ver_number>
        <文件集DIR =$ {} build.dir>
            <包括姓名= /&GT** / *。*;
        < /文件集>
    < /移动>
< /目标与GT;


解决方案

尝试移动/只重命名的目录,而不是它的全部内容。像这样的:

 <目标名称=rename_folder_jet取决于=Upload_on_ftp>
    <移动文件=$ {} build.dirtodir =$ {} build.dir _ _jet $ {} ver_number/>
< /目标与GT;

和确保您开始前,目标目录不存在。

我尝试用下面的生成文件:

 <项目默认=rename_folder_jet>
  <属性名=build.dirVALUE =构建/>
  <属性名=ver_numberVALUE =0.3/>  <目标名称=设置>
    < MKDIR DIR =$ {} build.dir/>
    < MKDIR DIR =$ {} build.dir /富/>
    < MKDIR DIR =$ {} build.dir /酒吧/>
  < /目标与GT;  <目标名称=拆解>
    <删除DIR =$ {} build.dir _ _jet $ {} ver_number/>
  < /目标与GT;  <目标名称=rename_folder_jet>
    <移动文件=$ {} build.dirtodir =$ {} build.dir _ _jet $ {} ver_number/>
  < /目标与GT;
< /项目>

在调试(蚂蚁-d)与上述执行Ant是有趣的。

案例1:

 蚂蚁拆机
蚂蚁设置
蚂蚁-d

在这种情况下,移动/重命名的目标目录不存在。蚂蚁的调试输出显示:

  [移动]试图重命名目录:C:\\用户\\须藤code \\ tmp目录\\蚂蚁\\建到C:\\用户\\须藤code \\ tmp目录\\蚂蚁\\ build_jet_0.3 \\构建

案例2:

 蚂蚁设置
蚂蚁
蚂蚁设置
蚂蚁-d

在此情况下,目标目录已经存在于第二执行。蚂蚁的调试输出显示:

  [移动]试图重命名目录:C:\\用户\\须藤code \\ tmp目录\\蚂蚁\\建到C:\\用户\\须藤code \\ tmp目录\\蚂蚁\\ build_jet_0.3 \\构建
文件集:在DIR C安装扫描仪:\\用户\\须藤code \\ tmp目录\\蚂蚁\\建立与patternSet {包括:[]不包括:[]}
     [举措]删除目录c:\\用户\\须藤code \\ tmp目录\\蚂蚁\\编译\\富
     [举措]删除目录c:\\用户\\须藤code \\ tmp目录\\蚂蚁\\编译\\酒吧
     [举措]删除目录c:\\用户\\须藤code \\ tmp目录\\蚂蚁\\构建

如此看来,如果目标目录不存在,蚂蚁会做的改名的目录。但如果目标目录存在,它,而不是做了的复制的进入目录,并从源目录,而不是删除。

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.

这篇关于重命名VS移动Ant任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆