ant task to delete files and directory that start with the same name

ant
32,763

Use a fileset to select files with a pattern, a dirset to select directories with a pattern.

This should do the job:

<delete>
    <dirset dir="${basedir}" includes="test*" />
    <fileset dir="${basedir}" includes="test*" />
</delete>
Share:
32,763
Decrypter
Author by

Decrypter

I have a strong passion for programming and a particular interest in web technologies. I love to experiment with interesting web technologies both server and client side.

Updated on June 29, 2020

Comments

  • Decrypter
    Decrypter almost 4 years

    In my folder example

    I have a directory called test. It contains many subfolders I also have files called test.properties and test.properties.sample

    I am trying to create an ant script to remove the files and directory

    Do I have to have 3 different tasks to delete these files?

    For example

    <delete dir="test" />
    <delete file="test.properties" />
    <delete file="test.properties.sample" />
    

    I would rather have something like

    <delete dir="test*" />
    

    so it deletes everything in the folder that starts with test