Under the src folder I have the following folders: daos, business and model. I want to delete using ant script, all the folders except "model". So I tried:
<delete includeemptydirs="true">
<fileset dir="${basedir}/src">
<include name="**/*"/>
<exclude name="model/*"/>
</fileset>
</delete>
All the folders are deleted, except "model" which is empty. All its files are deleted.
Deleting all files in the current Windows command line (DOS) directory, except files with a certain file extension, can best be done with the for command. In the example above, the command is deleting all files in the current directory, except files with the file extension . tiff and . jpg.
Select multiple files or folders that are not grouped together. Click the first file or folder, and then press and hold the Ctrl key. While holding Ctrl , click each of the other files or folders you want to select.
Try instead
<delete includeemptydirs="true">
<fileset dir="${basedir}/src">
<include name="**/*"/>
<exclude name="**/model/**"/>
</fileset>
</delete>
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