Hello Thomas,
the difficulty is you have probably an unlimited number of file separators between D:\in\ and "message.properties".
You need to write your own custom mapper.
The difficulty with regular expression is that there is no syntax I know of to back reference a pattern which repeats 0 to n times, like a path element.
I am attaching a solution.


Cheers,

Antoine



[EMAIL PROTECTED] wrote:

Hi all,
I have the following file in a directory

D:\In\com.isb.mira.model.ui.contrib.html\src\message.properties

and I would like to copy it to D:\Out\com.isb.mira.model.ui.contrib.html_src_message.properties

Any Idea ?
I've tried with mapper and regexp, with package and there is no way to get what I want.


Once got this, I would like to be able to do the opposite operation.

Thanks






<project name="copyit" default="all">
  <target name="setup">
    <delete dir="In" quiet="true"/>
    <delete dir="Out" quiet="true"/>
    <mkdir dir="In/com.isb.mira.model.ui.contrib.html/src"/>
    <mkdir dir="Out"/>
    <echo file="In/com.isb.mira.model.ui.contrib.html/src/message.properties">bonjour</echo>
  </target>
  <target name="copy">
     <typedef name="mymapper" classname="mymapper">
        <classpath>
          <pathelement location="."/>
        </classpath>
     </typedef>
     <copy todir="Out">
         <fileset dir="In">
            <include name="**/*.properties"/>
         </fileset>
         <mymapper/>
     </copy>
  </target>
  <target name="all" depends="setup,copy"/>
  <target name="compile">
     <javac destdir=".">
        <classpath>
           <pathelement location="c:/ant/lib/ant.jar"/>
        </classpath>
        <src>
          <pathelement location="."/>
        </src>
     </javac>
  </target>
</project>
import org.apache.tools.ant.util.FileNameMapper;
import java.io.File;
public class mymapper implements FileNameMapper {
    public void setFrom(String from) {}
    public void setTo(String to) {}
    public String[] mapFileName(String sourceFileName) {
        return new String[] {sourceFileName.replace(File.separatorChar, '_')};
    }
}

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

Reply via email to