ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
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">
      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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message