ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <>
Subject Re: how can I copy a directory of files to lower case equivalents?
Date Tue, 02 Oct 2007 12:35:34 GMT
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">

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 could always 
write the java mapper and provide it with tests as an ant enhancement 


Steve Loughran        
Author: Ant in Action 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message