我有一个填充的文件集,我需要将匹配的文件名打印到文本文件中.
我试过这个:
<fileset id="myfileset" dir="../sounds">
<include name="*.wav" />
<include name="*.ogg" />
</fileset>
<property name="sounds" refid="myfileset" />
<echo file="sounds.txt">${sounds}</echo>
Run Code Online (Sandbox Code Playgroud)
它将所有文件打印在一行中,以分号分隔.我需要每行一个文件.如何在不诉诸OS命令或编写Java代码的情况下完成此操作?
更新:
啊,应该更具体 - 列表不得包含目录.无论如何,我将ChssPly76标记为已接受的答案,因为pathconvert命令正是我所缺少的.要剥离目录并仅列出文件名,我使用了"flatten"映射器.
这是我最终得到的脚本:
<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>
Run Code Online (Sandbox Code Playgroud)
Chs*_*y76 67
使用PathConvert任务:
<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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
33145 次 |
| 最近记录: |