Martin
Martin

Reputation: 777

Ant renaming while copying file

How to rename file while copying it to directory in ant?

<copy file="..." todir="..." overwrite="true">

Upvotes: 30

Views: 35809

Answers (3)

hello_earth
hello_earth

Reputation: 1562

something like this also works, in case you want to specify a directory within the tofile attribute:

<target name="-post-jar" depends="init,compile">
    <copy file="${basedir}/src/query.txt" overwrite="true" tofile="${dist.dir}/input.txt" />
</target>

Upvotes: 0

Peter Szanto
Peter Szanto

Reputation: 7722

It should be as simple as

<copy file="mySourceFile" tofile="MyDestFile" />

Upvotes: 10

helios
helios

Reputation: 13841

Use tofile option instead of todir


Added

Or a more complex example from Ant Copy Task documentation:

Copy a set of files to a directory, appending .bak to the file name on the fly

  <copy todir="../backup/dir">
    <fileset dir="src_dir"/>
    <globmapper from="*" to="*.bak"/>
 </copy>

Upvotes: 52

Related Questions