ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Atherton <>
Subject Re: reverse glob mapper pattern?
Date Tue, 24 Sep 2002 00:52:31 GMT
At 05:05 AM 9/21/2002 -0500, Jacob Kjome wrote:

>Now what I'd like to do is set up a way to delete the files generated by 
>this copy.  So, I need to find all files that have a corresponding 
>"sample.*" file and delete those.
>If I just use the following, it deletes the sample.* file, not the * file 
>which is the opposite of what I want...
>         <delete>
>             <fileset
>                 dir="${src.dir}" >
>                 <present present="both" targetdir="${src.dir}">
>                     <mapper type="glob" from="sample.*" to="*" />
>                 </present>
>             </fileset>
>         </delete>
>So, my question is, how do I set up a pattern where the fileset will get a 
>list of the "*" files rather than the sample.* files to delete?

Reverse the mapper "from" and "to" attributes.

What you are asking  for in your fileset is all of the files in the 
${src.dir} that are named "sample.*" and that have a matching "*" file. 
What you want to be asking for is all the files named "*" for which there 
is a matching "sample.*". Change the mapper to:

     <mapper type="glob" from="*" to="sample.* />

and you will have better luck.

I'd also recommend an exclude of "sample.*" thrown in there so you aren't 
checking for the existence of "" or similar. Not 
necessary, but cleaner in understanding what the task is doing and a trifle 
more efficient. It would also have been clearer for debugging, as then your 
task wouldn't have done anything at all.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message