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
精彩评论