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
For historical reasons <delete dir="x"/> is different from <delete><fileset dir="x"/></delete> ; it will try to remove everything inside x including x itself, not taking default excludes into account, blindly following all symbolic links. If you need more control, use a nested <fileset> .
remove() method in Python is used to remove or delete a file path.
Use the rm command to remove files you no longer need. The rm command removes the entries for a specified file, group of files, or certain select files from a list within a directory.
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>
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