ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <qazw...@gmail.com>
Subject Re: Sorting file name
Date Fri, 19 Jun 2009 17:18:43 GMT
Well, it is sorting the files by name. Unfortunately, it is sorting them in
ASCII dictionary order.

The easiest way (and maybe the only way) is to zero fill in the names of
these files when you create them, so that you have 001.sql and 010.sql
instead of 1.sql and 10.sql.

That way, they'll sort in the order you want:

001.sql
002.sql
010.sql
011.sql

I looked at Resource Collections, and there is a <sort> resource collection,
but nothing to customize your sort order the way you want.

You could write your own task or script, but it's probably not worth it.


On Fri, Jun 19, 2009 at 7:15 PM, Henry Suhatman <henry@jawasoft.com> wrote:

> Hi all,
>
> I have use foreach task from ant-contrib, the output like this
> 1.sql
> 10.sql
> 11.sql
> 2.sql
>
> And, i want to sort file name like this:
> 1.sql
> 2.sql
> 10.sql
> 11.sql
>
> ----------------------------------------------------------------------------
> This is my code :
>
> ----------------------------------------------------------------------------
> <project name="check" default="testing">
>   <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
>   <target name="testing">
>       <foreach param="file" target="loop">
>           <path>
>               <fileset dir="army">
>                   <filename name="*.sql" />
>               </fileset>
>           </path>
>       </foreach>
>   </target>
>   <target name="loop">             <echo>${file}</echo>
>   </target>
> </project>
> -------------------------------------------------------------------------------
>
> What should do to solve this problem?
>
> Thanks & Regards,
>
>
>
> Henry
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 
David Weintraub
qazwart@gmail.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message