Steve Loughran wrote: > > 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 > > >
Thanks a lot for all the suggestions. I've upgraded Ant to 1.7 as I like this scriptmapper solution because it seems the simplest and most elegant. I've been trying to get it working but so far no joy. This is what I have: ... <copy todir="${build.dir}/images/characters/icons"> <fileset dir="images/characters/icons"/> <scriptmapper language="javascript"> self.addMappedName(source.toLowerCase()); </scriptmapper> </copy> ... But it currently does nothing at all. If I take out the scriptmapper task however it goes ahead and copies the 2000+ files (obviously not to lowercase names as I would like). My files are of the form, Archery_Aim.gif etc. and the uppercase characters can occur anywhere - I'm not sure if this is relevant but I thought I'd mention it. (I'm not bothered about directory names as they are all in lowercase anyway). -- View this message in context: http://www.nabble.com/how-can-I-copy-a-directory-of-files-to-lower-case-equivalents--tf4554266.html#a13133400 Sent from the Ant - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]