Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant target to move directories out of another directory

Tags:

java

task

ant


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)

like image 292
Krzysztof Miksa Avatar asked Dec 01 '10 10:12

Krzysztof Miksa


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:

  • <move> task
  • Mapper type
like image 76
Sean Patrick Floyd Avatar answered Oct 27 '22 22:10

Sean Patrick Floyd


Take 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>
like image 33
dogbane Avatar answered Oct 28 '22 00:10

dogbane