-----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]