开发者

Ant: renaming a group of files subject to a condition

I'm using Ant 1.8.2. Given a directory, how do I add an ".html" extension to all files in the directory and its sub-directories only if those files开发者_开发技巧 don't already have an .html extension?


There's an example in the Ant move task docs for renaming .bak files that is similar, here it is adjusted for .html files under a directory called my_dir:

<move todir="my_dir" includeemptydirs="false">
    <fileset dir="my_dir">
        <exclude name="**/*.html" />
    </fileset>
    <mapper type="glob" from="*" to="*.html" />
</move>

The fileset excludes files that already have the target extension, the mapper defines the renaming pattern.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜