如何使用Ant任务将目录移动到一个目录?
我的目录结构如下:
my/directory/root
|-dir1/one/same/lib
|-dir2/two/same/lib
|-dir3/three/same/lib
|-dir4/four/same/lib
我想移动并缩放文件夹“same / lib”并将其移至“my / directory / root”
(最后:my / directory / root / same / lib)
答案 0 :(得分:4)
这样的事情应该有效:
<target name="moveDirs">
<mkdir dir="my/directory/root/merged" failonerror="false">
<move todir="my/directory/root/merged">
<fileset dir="my/directory/root">
<include name="dir*/*"/>
</fileset>
<mapper>
<regexpmapper from="^(.*?)dir[0-9]+.(.*)$" to="\1\2"/>
</mapper>
</move>
</target>
<强>参考:强>
答案 1 :(得分:1)
看看Ant Move Task。 请尝试以下方法:
<target name="moveDirs">
<mkdir dir="my/directory/root/same/lib" failonerror="false">
<move todir="my/directory/root/same/lib">
<fileset dir="my/directory/root/dir1/one/same/lib">
<include name="**/*"/>
</fileset>
</move>
<move todir="my/directory/root/same/lib">
<fileset dir="my/directory/root/dir2/two/same/lib">
<include name="**/*"/>
</fileset>
</move>
<move todir="my/directory/root/same/lib">
<fileset dir="my/directory/root/dir3/three/same/lib">
<include name="**/*"/>
</fileset>
</move>
<move todir="my/directory/root/same/lib">
<fileset dir="my/directory/root/dir4/four/same/lib">
<include name="**/*"/>
</fileset>
</move>
</target>