Thanks... I ended up doing this:

                                                                                
<property name="syncreport.exists" value="false" />
                                                                                
<foreach item="File" property="syncreport.find">
                                                                                
                <in>
                                                                                
                                <items basedir="${PublishDir}/DbPackagers">
                                                                                
                                                <include name="SyncReport*.txt" 
/>
                                                                                
                                </items>
                                                                                
                </in>
                                                                                
                <do>
                                                                                
                                <echo message="Syncreport file name is: 
${syncreport.find}" />
                                                                                
                                <property name="syncreport.exists" value="true" 
/>
                                                                                
                                <property name="syncreport" 
value="${syncreport.find}" />
                                                                                
                </do>
                                                                                
</foreach>

Which works fine since there will only ever be 1 or 0 files that match the 
pattern. Although I did learn something new, that the property on the foreach 
loop is scoped to the foreach loop. I had thought all properties were global. 
Oh well, live and learn.

I never think to look at the contrib document for functions, only tasks. I'll 
have to remember that one.

BOb


From: Bill Martin [mailto:w.p.mar...@blueyonder.co.uk]
Sent: Friday, July 24, 2009 5:24 PM
To: Bob Archer; nant-users@lists.sourceforge.net
Subject: RE: [NAnt-users] Does a file matching a pattern exist...

You could use a fileset and then use the 
fileset::has-files(http://nantcontrib.sourceforge.net/release/latest/help/functions/fileset.has-files.html
 ) function in NAntContrib.

HTH,
Bill

________________________________
From: Bob Archer [mailto:bob.arc...@amsi.com]
Sent: 24 July 2009 17:20
To: nant-users@lists.sourceforge.net
Subject: [NAnt-users] Does a file matching a pattern exist...

Hi All,

What is the easiest was to check if a file exists if I don't have the file 
name. I have the pattern that the file will match. The only think I can think 
to do is to use a foreach with the pattern and put the file name into a 
property.

Is there an easier way that is cleaner?

Thanks,
BOb


No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.392 / Virus Database: 270.13.27/2258 - Release Date: 07/24/09 
05:58:00
------------------------------------------------------------------------------
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to