ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mario Madunic <haj...@imag.net>
Subject getting filename from dir listing
Date Fri, 21 Sep 2007 14:58:40 GMT
I would like to get the filename of the first file in a directory and then get a
particular part of the filename. The files all basically follow this format:
20070921_0001.xml. Currently I'm using a combination of windows command line and
ant. It looks like the following

in a bat file (I know it could be done using the exec task in ANT but haven't
got off my ass to change it)
dir drop /b > prefix.txt

in an ANT task

<replaceregexp match="\s+" replace="" file="../prefix.txt" flags="g"
byline="false" encoding="utf-8" />

<!-- get the first 8 chars from the string in prefix.txt -->
<replaceregexp match="^(\w{8})([a-zA-Z0-9\_\-\.\~])*" replace="\1"
file="../prefix.txt" flags="g" byline="false" encoding="utf-8" />

<!-- set the value of l_Docset with the first line from prefix.txt -->
<loadfile property="l_Docset" srcFile="../prefix.txt">
<filterchain>
<headfilter lines="1"/>
</filterchain>
</loadfile>

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

Any help or ideas will be greatly appreciated.

Marijan (Mario) Madunic


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


Mime
View raw message