I want to delete all directories and subdirectories under a root directory that are contain "tmp" in their names. This should include any .svn files too. My first guess is to use
<delete>
<dirset dir="${root}">
<include name="**/*tmp*" />
</dirset>
</delete>
This does not seem to work as you can't nest a dirset
in a delete
tag.
Is this a correct approach, or should I be doing something else?
Here's the answer that worked for me:
<delete includeemptydirs="true">
<fileset dir="${root}" defaultexcludes="false">
<include name="**/*tmp*/**" />
</fileset>
</delete>
I had an added complication I needed to remove .svn
directories too. With defaultexcludes
, .*
files were being excluded, and so the empty directories weren't really empty, and so weren't getting removed.
The attribute includeemptydirs
(thanks, flicken, XL-Plüschhase) enables the trailing **
wildcard to match the an empty string.
try:
<delete includeemptydirs="true">
<fileset dir="${root}">
<include name="**/*tmp*/*" />
</fileset>
</delete>
ThankYou flicken !
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