I am want to copy all directory to another directory but also I must rename one file. I am trying this:
<copy todir="destDir" enablemultiplemappings="true">
<fileset dir="sourceDir"/>
<compositemapper>
<identitymapper />
<globmapper from="oldFileName" to="newFileName"/>
</compositemapper>
</copy>
But this task copy all files, and than copy renamed file. And in destDir directory I have two files: destDir\oldFileName and destDir\newFileName. But I need only destDir\newFileName. Can someone help me with this?
EDITED: I need to copy all files form sourceDir to destDir, and rename only file with name "oldFileName".
Set enablemultiplemappings="false", and swap the order of your mappers:
<copy todir="destDir">
<fileset dir="sourceDir" />
<compositemapper>
<globmapper from="oldFileName" to="newFileName" />
<identitymapper />
</compositemapper>
</copy>
Without multiple mappings enabled the first mapping that produces a filename 'wins'. So for the files needing a rename, the glob will apply. For all other files the identity mapper will name them as-is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With