Hi,

Mario Madunic wrote:
I would like to get the filename of the first file in a directory and then get a
particular part of the filename.

There has to be a much easier and cleaner way of doing this.

You want the first part of the filename, right ?

with a dir like that =
J:\test>dir /B
20070921_0001.xml
20070921_0002.xml
20070921_0003.xml

you can go with <script>, and put the
string in a property for further
ant processing, i.e. =

<script language="ruby">
<![CDATA[
str=File.basename(Dir["J:/test/*.xml"].sort[0]).gsub(/(\w{8}).+/, $1)
$project.setProperty "myproperty", str
]]>
</script>
...
<echo>
$${myproperty} == ${myproperty}
</echo>

will give you =
${myproperty} == 20070921

Regards, Gilbert




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to