Thanks Gilbert for quick response.
The first solution would be suitable for my current issue &  it worked out.

Currently i am using Ant1.6.5 and in Ant Manual [for 1.6.5] for FileSets i
don't see "id" attribute in the Attribute || Description || Required table.
Can you please check if this information is updated in ant1.7 manual?

Thanks once again

Regards
Rohit

On Tue, Nov 18, 2008 at 3:34 PM, Rebhan, Gilbert <
[EMAIL PROTECTED]> wrote:

> -----Original Message-----
> From: Rohit P [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 18, 2008 10:16 AM
> To: Ant Users List
> Subject: Verifying existence of files under a directory
>
> /*
> But before i do the 'concat' action i need to verify if there are files
> under ${REPORTS_DIR}. Can you let me know the ways to check if *.csv files
> exist under ${REPORTS_DIR} before concatenating them into 'abc.csv'?
> */
>
> two possible solutions =
>
> 1. use your fileset, just checking if your fileset catches
>    any files
>
> <fileset dir="${REPORTS.DIR}" includes="**/*.csv" id="checkdir"/>
>
> <condition property="nofiles">
>  <equals arg1="${toString:checkdir}" arg2="" />
> </condition>
>
> <fail if="nofiles" message="No Files around !!" />
>
>
> 2. or use script, with a scripting language you like
>     if you need to check for a certain quantity of files
>
> <scriptdef name="filecount" language="ruby">
> <attribute name="dir"/>
> <attribute name="ext"/>
> <attribute name="property"/>
> <![CDATA[
>  $project.setNewProperty $attributes.get('property'),
>
>  
> Dir.glob("#{$attributes.get('dir')}/**/*.#{$attributes.get('ext')}").length.to_s
>  puts "Result = " +
> Dir.glob("#{$attributes.get('dir')}/**/*.#{$attributes.get('ext')}").length.to_s
> ]]>
> </scriptdef>
>
> <filecount dir="${REPORTS.DIR}" ext="csv" property="filecount"/>
> <condition property="nofiles">
>  <equals arg1="${filecount}" arg2="0" />
> </condition>
> <fail if="nofiles" message="No Files around !!" />
>
>
> Regards, Gilbert
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to