How to move directories to one directory using an Ant task?
My directory structure is like:
my/directory/root
|-dir1/one/same/lib
|-dir2/two/same/lib
|-dir3/three/same/lib
|-dir4/four/same/lib
And I would like to move and scale folders "same/lib" and move it to "my/directory/root"
(finally: my/directory/root/same/lib)
Something like this should work:
<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>
Reference:
<move>
taskTake a look at the Ant Move Task. Try the following:
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With