fileset - Iterating through a directory with Ant -


Assume that I have a collection of PDF files with the following paths:

  / Some /path/pdfs/birds/duck.pdf/some/path/pdfs/birds/goose.pdf/some/path/pdfs/insects/fly.pdf /some/path/pdfs/insects/mosquito.pdf  

What I want to do is generate thumbnails for each PDF that respects the relative path structure, and outputs at some other place, such as:

  / Another / path / thumbnail / bird / duck page / other / path / thumbnail / bird / goes page / NY / path / thumbnail / Insekts / Fliking / other / path / thumbnail / Insekts / Mojkito.  

I want that to be done in ant assume that I am going to use a ghost script on the command line and I have already called for GS:

  & lt; Exec executable = "$ {ghostscript.executable.name}" & gt; & Lt; Arg value = "- q" / & gt; & Lt; Arg value = "-r72" /> & Lt; Arg value = "- sDEVICE = png16m" /> & Lt; Arg value = "- sOutputFile = $ {thumbnail.image.path}" /> & Lt; Arg value = "$ {input.pdf.path}" /> & Lt; / Executive & gt;  

So what do I need to do is correct values ​​for $ {thumbnail.image.path} and $ {input.pdf.path} Working)} crossing the PDF input directory.

I have access to ant-contrib (just "latest", which is 1.0b3) and I am using ant 1.8.0. I feel that I & lt; For & gt; task, & lt; Fileset & gt; s and & lt; Mapper & gt; I can do something by using the s, but I have trouble having trouble with all this.

I tried to do something like this:

"code" & gt; & Lt; Path & gt; & Lt; Fileset dir = "$ {some.dir.path} / pdfs" & gt; & Lt; Include name = "** / * .pdf" /> & Lt; / Fileset & gt; & Lt; / Path & gt; & Lt; Sequential & gt; & Lt; Echo message = "@ {file}" /> & Lt; / Sequential & gt; & Lt; For / & gt;

But unfortunately @ {file} property is a complete path, and I can not find any easy way to weaken it in relative components.

If I can do this only by using a custom function, I think I can write one, but I hope that I can only plug the existing components together.

In sequential tasks, you are able to use the function to map the input path to the output You can. For example:

  & lt; Propertyregex override = "yes" property = "outfile" input = "@ {file}" regexp = "/ some / path / pdfs /(.*) .pdf" replacement = "/ other / path / \ 1.png" / & Gt;  

Which map, for example /some/path/pdfs/birds/duck.pdf to / another / path / birds / duck. Png .


Comments