Ant target to move directories from another directory


How to move directories to a single directory using the Ant task?

My directory structure is similar:

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 the "same / lib" folders and move them to "my / directory / root"
(finally: my / directory / root / same / lib)

+6
java ant task
source share
2 answers

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:

+4
source share

See Ant Task Moving . 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> 
+1
source share

All Articles