Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete folders except one

Tags:

ant

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.

like image 298
senior Avatar asked Mar 25 '13 16:03

senior


People also ask

How do I Delete all files except one in Windows?

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.

How do I select all except one folder?

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.


1 Answers

Try instead

<delete includeemptydirs="true">
    <fileset dir="${basedir}/src">
        <include name="**/*"/>
        <exclude name="**/model/**"/>
    </fileset>
</delete>
like image 147
VirtualTroll Avatar answered Nov 15 '22 12:11

VirtualTroll