开发者

how can we extract the file extension of a file using ant script?

The scenario is as follows:

Therea are three files :

test.xls test.txt test.doc

I am working with mqfte right now. When these files are transferred to another location the filenames must be as below :

result_xls.txt result_txt.txt result_doc.txt

Could anyone help on this?

Can this fil开发者_JAVA技巧ename renaming done with ant scripts?


Try this:

<target name="test">
  <copy todir="dest">
    <fileset dir="src">
      <include name="test*"/>
    </fileset>
    <globmapper from="test.*" to="result_*.txt"/>
  </copy>
</target>

Input:

  $ find src
  src
  src/test.doc
  src/test.txt
  src/test.xls

Output:

  $ find dest/
  dest/
  dest/result_doc.txt
  dest/result_txt.txt
  dest/result_xls.txt


Sure, you can use the Move Ant Task http://ant.apache.org/manual/Tasks/move.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜