I have a populated fileset and I need to print the matching filenames into a text file.
I tried this:
<fileset id="myfileset" dir="../sounds"> <include name="*.wav" /> <include name="*.ogg" /> </fileset> <property name="sounds" refid="myfileset" /> <echo file="sounds.txt">${sounds}</echo>
which prints all the files on a single line, separated by semicolons. I need to have one file per line. How can I do this without resorting to calling OS commands or writing Java code?
UPDATE:
Ah, should have been more specific - the list must not contain directories. I'm marking ChssPly76's as the accepted answer anyway, since the pathconvert command was exactly what I was missing. To strip the directories and list only the filenames, I used the "flatten" mapper.
Here is the script that I ended up with:
<fileset id="sounds_fileset" dir="../sound"> <include name="*.wav" /> <include name="*.ogg" /> </fileset> <pathconvert pathsep="
" property="sounds" refid="sounds_fileset"> <mapper type="flatten" /> </pathconvert> <echo file="sounds.txt">${sounds}</echo>
You can find this option under File / Print / Advanced / Mark and Bleeds / Page Information. This will take the file name and automatically place on the output. If you want more control then use the Document / Add Header / Footer command (or indeed any of the ones in the top category) ..
A FileSet is a group of files. These files can be found in a directory tree starting in a base directory and are matched by patterns taken from a number of PatternSets and Selectors.
Use the PathConvert task:
<fileset id="myfileset" dir="../sounds"> <include name="*.wav" /> <include name="*.ogg" /> </fileset> <pathconvert pathsep="${line.separator}" property="sounds" refid="myfileset"> <!-- Add this if you want the path stripped --> <mapper> <flattenmapper /> </mapper> </pathconvert> <echo file="sounds.txt">${sounds}</echo>
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