ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marijan (Mario) Madunic" <haj...@imag.net>
Subject Re: getting filename from dir listing
Date Sun, 30 Sep 2007 17:15:50 GMT
Thanks Dale,

This is really interesting and will read the documentation and see what 
else is available.

Marijan (Mario) Madunic

Dale Anson wrote:
> Another alternative is to use the FileUtils and StringUtils from 
> Antelope, http://antelope.tigris.org.  Here's an example:
>
>      <fileutil file="${ant.library.dir}" property="file_list">
>        <listfiles includepath="false"/> <!-- just filenames, no paths -->
>      </fileutil>
>
>      <stringutil string="${file_list}" property="first_8">
>        <substring endindex="8"/> <!-- default start index is 0 -->
>      </stringutil>
>      <echo>first 8 characters of file name = ${first_8}</echo>
>
> This will show the first 8 characters of the first file in Ant's lib 
> directory.
>
> Dale
>
>
> Gilbert Rebhan wrote:
>> Mario Madunic wrote:
>>> Thanks Gilbert.
>>>
>>> I ran a test of your script and received the following error.
>>
>> sorry was untested, use =
>>
>> <script language="ruby">
>> <![CDATA[ 
>> str=File.basename(Dir["J:/test/*.xml"].sort[0]).gsub(/(\w{8}).+/, '\1')
>> $project.setProperty "myproperty", str
>> ]]>
>> </script>
>>
>> means use '\1' instead of $1 in the gsub part
>> and it will work.
>>
>> Regards. Gilbert
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message