ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilbert Rebhan <>
Subject Re: getting filename from dir listing
Date Fri, 21 Sep 2007 18:18:51 GMT


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

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

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

will give you =
${myproperty} == 20070921

Regards, Gilbert

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

View raw message