I need to develop an ANT script that reads a directory content. The files in this directory are numbered along with its name. I have to find the largest numbered file in this directory and return its name and the number.
For example:
>> ls
patch-aaa-050.jar
patch-aaa-051.jar
patch-aaa-052.jar
patch-aaa-053.jar
patch-aaa-054.jar
patch-aaa-055.jar
I need to echo out: Latest patch is patch-aaa-055: Patched level: 55
Although this is a very easy task in Bash, PowerShell or Python
. I am a bit clueless in ANT. I have checked out dirset
Type and fileset
Type. These types are able to list the directories but parsing the file names are overwhelming for me. The design is to run only with ANT, so I am limited to use that tool.
Thanks
Use resource collection path combined with basename and script task, f.e.:
There are also other possibilities for sort, see ant manual