Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete all the subfolder under some folder in Ant?

Tags:

ant

Suppose I have

/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?

like image 844
performanceuser Avatar asked Oct 08 '11 19:10

performanceuser


2 Answers

Please check this :

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

If you don't want to specify A, B, C you will have to do some nasty trict for recursively searcing all subdirectories. I have done this with a custom java script.

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

<delete includeEmptyDirs="true">
  <fileset dir="root" includes="**/to_delete/"/>
</delete>
like image 110
FailedDev Avatar answered Oct 31 '22 15:10

FailedDev


Please try the below code and it works to remove the dir and sub dirs as well.

<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>
like image 29
mannedear Avatar answered Oct 31 '22 13:10

mannedear