0

I'm trying to delete directories and its content using ant, but onlt the content gets deleted. The directory is still existing. What am I miising?

<delete failonerror="false">
   <dirset dir="C:\profile\${profileName}\installedApps\Cell${profileName}">
    <include name="${projectName}**/*"/>
   </dirset>
</delete>
soninob
  • 428
  • 11
  • 22

1 Answers1

1

Simply use the delete task with the dir attribute set to the parent directory:

<delete dir="C:\profile\${profileName}\installedApps\Cell${profileName}" />

Edit: In response to your comment, here's how to delete all of the directories (and their files) with a certain name pattern that exist within a parent directory.

<property name="profile.dir" location="C:\profile\${profileName}\installedApps\Cell${profileName}" />

<delete>
    <fileset dir="${profile.dir}" includes="${projectName}*/**/*" />
    <dirset dir="${profile.dir}" includes="${projectName}*/**" />
</delete>

Setting the profile.dir property prior to running the delete task is of course optional, but recommended.

CAustin
  • 4,525
  • 13
  • 25