title: Deleting files matching a placeholders in another directory tree
body: <p>I have two directory trees:</p>
  
  <pre><code>source/aaa/bbb/ccc/file01.txt
  source/aaa/bbb/file02.txt
  source/aaa/bbb/file03.txt
  source/aaa/ddd/file03.txt
  source/file01.txt
  </code></pre>
  
  <p>and</p>
  
  <pre><code>template/aaa/bbb/ccc/file01.txt
  template/aaa/bbb/DELETE-file03.txt
  template/aaa/DELETE-ddd
  template/DELETE-file01.txt
  </code></pre>
  
  <p>Using Ant, I want to do three things. First, I want to copy any files from "template" into "source", such that all files not starting with "DELETE-" are replaced. For example, "source/aaa/bbb/ccc/file01.txt" would be replaced. This is straightforward with:</p>
  
  <pre><code>&lt;copy todir="source" verbose="true" overwrite="true"&gt;
      &lt;fileset dir="template"&gt;
          &lt;exclude name="**/DELETE-*"/&gt;
      &lt;/fileset&gt;
  &lt;/copy&gt;
  </code></pre>
  
  <p>Second, I want to delete all files in the "source" tree whose name matches a "DELETE-" file in the corresponding directory of the "template" tree. For example, both "source/aaa/bbb/file03.txt" and "source/file01.txt" will be deleted. I have been able to accomplish this with:</p>
  
  <pre><code>&lt;delete verbose="true"&gt;
      &lt;fileset dir="source"&gt;
          &lt;present present="both" targetdir="template"&gt;
              &lt;mapper type="regexp" from="(.*[/\\])?([^/\\]+)" to="\1DELETE-\2"/&gt;
          &lt;/present&gt;
      &lt;/fileset&gt;
  &lt;/delete&gt;   
  </code></pre>
  
  <p>Third, I'd like to delete any directories (empty or not) whose names match in the same way. For example, "template/aaa/DELETE-ddd" and all file(s) under it would be deleted. I'm not sure how to construct a fileset that matches directories (<em>and all the files under them</em>) in the "source" tree where the directory has a DELETE-* file in the "template" tree.</p>
  
  <p>Is this third task even possible with Ant (1.7.1)? I'd preferrably like to do this without writing any custom ant tasks/selectors.</p>