During my build process I copy files from one directory to another, filtering out some unnecessary text like so:
<target name="init-files">
<copy todir="${resources}/clean" overwrite="true">
<fileset dir = "${resources}/dirty" />
<filterchain>
<tokenfilter>
<replacestring from="text_to_remove" to="" />
</tokenfilter>
</filterchain>
</copy>
</target>
I would like to insert a line of text at the beginning and end of each file being copied. I cannot use replacestring as I can’t insert a token – the source text files are generated externally.
concat looked like the answer but while I’ve found how to concatenate a collection of files into a single file (many sources with single destination) I don’t see how to add text to each file in a collection (fixed text source with many destination).
I’d appreciate any ideas on how to accomplish this.
Thank you!
There’s the
replaceregexstring filter that can be chained with thereplacestringfilter you already have in the tokenfilter:The first one matches the start of each of the files, the second the end.