I'm trying to create a comma-delimited list of files or directories under the current directory. For instance, suppose I have the following folder structure:
Root -- Directory1 -- Directory2 ...
I want to generate a variable or property that contain "Directory1,Directory2." I've tried iterating (using ant-contrib "for" task) over a <dirset dir="." includes="*">
, but this generates absolute paths; I've then extracted the file names using the "basename" task, however that in turn generates an output property. Since properties are immutable, what I get in practice is "Directory1,Directory1,..."
Is there a saner way of doing this, or will I have to write a Java extension to do this for me?
The pathconvert
task can be used to format a dirset with arbitrary separators:
<dirset id="dirs" dir="." includes="*"/>
<pathconvert dirsep="/" pathsep="," property="dirs" refid="dirs"/>
<echo message="${dirs}"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With