Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I delete files with one extension for corresponding files with some other extension, using Ant?

Tags:

ant

Using Ant, I would like to clean a directory of all files having the extension '.dcu' for which a file exists that has the same basename with the extension '.pas'.

I cannot simply delete all '.dcu' files - some of them cannot be restored by compiling from source, because there is no corresponding '.pas' file.

How can this be done?

like image 514
unassigned Avatar asked Feb 27 '23 14:02

unassigned


1 Answers

You can do this using a fileset with a glob mapper and the present selector, for example:

<delete>
    <fileset dir="." includes="*.dcu">
        <present targetdir=".">
            <mapper type="glob" from="*.dcu" to="*.pas" />
        </present>
    </fileset>
</delete>
like image 151
martin clayton Avatar answered Apr 12 '23 13:04

martin clayton