0

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 filename renaming done with ant scripts?

trilawney
  • 1,786
  • 6
  • 28
  • 36

2 Answers2

1

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
ewan.chalmers
  • 16,145
  • 43
  • 60
  • Can you suggest something for the below question http://stackoverflow.com/questions/5870083/to-display-a-read-error-when-the-source-file-is-used-by-other-applications-while – trilawney May 26 '11 at 13:03
  • When i use the following code after a filecopy task in same target with a filecopy task, it is not working. Note the outcome property is defer in filecopy. is the problem due to outcome=defer. – trilawney May 30 '11 at 13:28
  • I am transferring the file from the source to dest. After reaching the destination i should rename it in the same folder itself. – trilawney May 30 '11 at 13:39
0

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

Karl-Bjørnar Øie
  • 5,554
  • 1
  • 24
  • 30