dcsimg
Changing filename from upper to lowercase
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Adam_Clark
Posted On:   Friday, March 17, 2006 01:33 PM

I have a series of files that need to be converted to a common format. ie. P1075.ABC => P1075.abc p1075.Abc => P1075.abc I would like to do this when the file gets moved or copied from my source directory to my deploy directory. I can get the file extension to be converted using a globmapper inside the move command, but can't seems to figure out what I need to do to make everything preceeding the '.' to be the way I want. This is what I have now, and was told that a regexp wouldn't be able to work with this. Any help is appreciated.    More>>

I have a series of files that need to be converted to a common format.

ie. P1075.ABC => P1075.abc

p1075.Abc => P1075.abc


I would like to do this when the file gets moved or copied from my source directory to my deploy directory. I can get the file extension to be converted using a globmapper inside the move command, but can't seems to figure out what I need to do to make everything preceeding the '.' to be the way I want.

This is what I have now, and was told that a regexp wouldn't be able to work with this.

			









Any help is appreciated.    <<Less

Re: Changing filename from upper to lowercase

Posted By:   Robert_Lybarger  
Posted On:   Wednesday, April 5, 2006 01:54 PM

my cursory look through the docs show your need might be just slighly to fancy for the core task behaviors for . have you considered a custom (user-defined) task via your own java class to accomplish this? You could construct it in such way that an ordinary, nested could pass you the list of files to operate on.




  • extend org.apache.tools.ant.Task

  • implement: public void addFileSet(org.apache.tools.ant.types.FileSet fs_obj) { /* add the fs_obj to a Vector (to support multiple FileSets for example), or whatever to store the reference */ }

  • implement public void execute() throws BuildException { /* put your stuff to rename the file here */ }

  • Note that for a given FileSet object, you get the list of files from the toString() method, noting all returned files are concatenated together with a semi-colon. suggest a StringTokenizer or something

  • compile to a class and jar it up

  • use a ant task to reference your class name against some new ant task name and ensure your jar file is in the classpath at some point

  • use your new task name instead of the default 'move' task.


About | Sitemap | Contact