How to delete the entire subfolder under any folder in the Ant folder?

Let's pretend that

/Root /A /to_delete /not_to_delete /B /to_delete /not_to_delete /C /to_delete /not_to_delete 

How to delete those folders called "to_delete" in Ant?

+7
source share
2 answers

Please check it:

http://ant.apache.org/manual/Tasks/delete.html

If you do not want to specify A, B, C, you will have to do some nasty trick to recursively search all subdirectories. I did this using a custom java script.

If you can specify A, B, C, although you just need something:

 <delete includeEmptyDirs="true"> <fileset dir="root" includes="**/to_delete/"/> </delete> 
+10
source

Please try the code below and it also works to remove the directory and auxiliary files.

 <delete includeEmptyDirs="true"> <fileset dir="${dir.to.delete}"> <include name = "**" /> <exclude name = "**/.svn" /> <!-- in case you want to skip .svn folders to avoid SVN conflicts --> </fileset> </delete> 
+1
source

All Articles