tags:

views:

646

answers:

1

What is the simplest way to move everything out of a target directory?

I have this basedir/parentdir/<subdir>. I have many different <subdir>. I need to move them out into the same level as parentdir so that it becomes basedir/<subdir>. Now, each <subdir> contains a deep tree of many other subdirectories and files, including empty subdirectories.

I've tried the following:

<move todir="basedir">
    <fileset dir="parentdir">
        <include name="**/*.*" />
    </fileset>
</move>

That failed to move the empty directories - meaning after the move, all the <subdir> are missing their empty subdirectories. "move" supposedly copies emptysubdirectories by default, so I tried the following next:

<move todir="basedir">
    <fileset dir="parentdir">
        <include name="**/*" />
        <include name="**/*.*" />
    </fileset>
</move>

While I did manage to move the empty subdirectories, the strange thing is that all the immediate subdirectories of all the <subdir> gets copied into basedir. Every <subdir> has src, test, and build. These are now sitting in basedir as well as in their original moved <subdir>.

I'm positive I'm doing something wrong but I don't know what. Am I approaching things the wrong way?

+2  A: 

Try this

<project name="moveproject" basedir="." default="moveDirs">
<target name="moveDirs">
    <move todir="${basedir}" includeEmptyDirs="yes" verbose="true">
     <fileset dir="parentdir" >
      <include name="**/*" />
     </fileset>
    </move>
</target>
</project>
Ram
includeEmptyDirs is supposed to be true by default so I didn't set it. Also, the example in Ant doc used includeemptydirs="false" instead of yes/no... strange. **/* was correct. I scrapped my old targets and rewrote most of it. I think my original target that set up the parentdir had problems. Copied yours in and things are working as intended. Thanks!
aberrant80