Ken Madsen
Ken Madsen

Reputation: 21

Ant to delete subdirectories and files in subdirectories but not any file from the directory itself

My requirement is to delete all subdirectories from a specified directory, but NOT delete files in the specified directory.

I have fussed around with fileset and dirset and I could not get a single collection to do the job. What works is this:

<delete includeemptydirs="true" verbose="true" >
    <fileset dir="release/reports" >
        <exclude name="*.*" />
    </fileset>
    <dirset dir="release/reports" includes="**/*" />
</delete>

Isn't there a way to do this with one collection (either fileset or dirset)?

Upvotes: 2

Views: 2200

Answers (1)

Rebse
Rebse

Reputation: 10377

It should work like that :

 <delete includeEmptyDirs="true">
  <fileset dir="C:/yourdir" includes="**/*" excludes="*.*"/>
 </delete>

Upvotes: 1

Related Questions