Alx G wrote:
Hi,

Does anyone know if there's anything in Ant that can copy files from a
directory to another directory but change all the file names to lower case?

e.g.

working/some_folder/etc/Blah.jpg => dist/some_folder/etc/blah.jpg
...
etc. for a whole load of files in various directories.

Perhaps there's something I can add to this?

<copy todir="${dist.dir}/images">
    <fileset dir="images"/>
</copy>

If there's nothing in Ant directly, I'm going to have to write a PHP script
that does the renaming but I'd prefer not to create more scripts.

Any help would be much appreciated.

Many Thanks!


The ant-approved way would be a <copy> with an appropriate mapper listed as a nested element. This gives copy the mapping from input filenames to output names, lets it do the copying and dependency management as normal. You just provide the renaming logic .

I dont see one, but I do see in the manual the <scriptmapper> example, which (ant1.7+ only) would let you do what you want in a few lines


 <copy todir="${dist.dir}/images">
     <fileset dir="images"/>
    <scriptmapper language="javascript">
     self.addMappedName(source.toLowerCase());
   </scriptmapper>
 </copy>

If you are running on java6, javascript is built in -no need for extra JARs to get scripting working.

Case conversion does sound like a common use case...you could always write the java mapper and provide it with tests as an ant enhancement bugrep.

-steve

--
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to