假设我有一个包含以下路径的 PDF 文件集合:
/some/path/pdfs/birds/duck.pdf
/some/path/pdfs/birds/goose.pdf
/some/path/pdfs/insects/fly.pdf
/some/path/pdfs/insects/mosquito.pdf
我想要做的是为每个 PDF 生成尊重相对路径结构的缩略图,并输出到另一个位置,即:
/another/path/thumbnails/birds/duck.png
/another/path/thumbnails/birds/goose.png
/another/path/thumbnails/insects/fly.png
/another/path/thumbnails/insects/mosquito.png
我希望这可以在 Ant 中完成。假设我要在命令行上使用 Ghostscript,并且我已经完成了对 GS 的调用:
<exec executable="${ghostscript.executable.name}">
<arg value="-q"/>
<arg value="-r72"/>
<arg value="-sDEVICE=png16m"/>
<arg value="-sOutputFile=${thumbnail.image.path}"/>
<arg value="${input.pdf.path}"/>
</exec>
所以我需要做的是计算出正确的值${thumbnail.image.path}
and ${input.pdf.path}
遍历 PDF 输入目录时。
我可以访问 ant-contrib(刚刚安装了“最新”版本,即 1.0b3)并且我正在使用 Ant 1.8.0。我想我可以使用<for>
task, <fileset>
s and <mapper>
s,但我很难将它们放在一起。
我尝试过类似的事情:
<for param="file">
<path>
<fileset dir="${some.dir.path}/pdfs">
<include name="**/*.pdf"/>
</fileset>
</path>
<sequential>
<echo message="@{file}"/>
</sequential>
</for>
但不幸的是@{file}
property 是绝对路径,我找不到任何简单的方法将其分解为相关组件。
如果我只能使用自定义任务来完成此操作,我想我可以编写一个,但我希望我可以将现有组件插入在一起。