ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Charles Daniels" <c...@yahoo.com>
Subject RE: rename file with mapper
Date Tue, 10 Aug 2004 21:36:54 GMT
> -----Original Message-----
> From: thilo boehm [mailto:thilo.boehm@gmail.com]
> Sent: Tuesday, August 10, 2004 8:02 PM
> To: Ant Users List
> Subject: Re: rename file with mapper
>
>
> Thanks a lot for your help.
> It looks like the mapper only works in the current directory, but I
> want to rename the files recursively. I always looked at a deeper
> directory, that's why I thought the task is not working.
> Any ideas?

In general, mapper does not work only in the current directory.  It is
working that way for you because the values you have supplied for the from
and to attributes (from="LIVE_*" to="*").  The from and to values must take
into account the entire path of the file (relative to the current
directory), not just the filename.  Since only the files in the current
directory have no relative path, those are the only ones renamed with the
values you are using.

However, since the glob mapper can only have one wildcard, you cannot
specify from="*LIVE_*" and to="**", which is what you really want.
Therefore, you must use the regexp mapper, as you also tried.  Again,
though, your attempt as using the regexp mapper suffered the same problem --
you didn't take the relative path into account.  So you need your regexp
mapper to look like this (not tested):

  <mapper type="regexp" from="(.*)LIVE_(.*)" to="\1\2" />

In theory, that should do what you want.  I leave it to you to see if it
works in practice.

>
> -Thilo
>
>
> On Tue, 10 Aug 2004 13:02:08 -0400, Saha, Sanjeev <ssaha@asce.org> wrote:
> > Here is a sample build file that I used to test your concern.
> It works perfectly fine for your needs. Surprisingly, it is not
> much different than the one that you are trying to use. Hope it helps!!
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <project basedir="." default="rebuild" name="test">
> >  <property name="dir" value="."/>
> >  <target name="rename">
> >    <move todir="${dir}" includeemptydirs="false">
> >      <fileset dir="${dir}" includes="**/*"/>
> >      <mapper type="glob" from="LIVE_*" to="*"/>
> >    </move>
> >  </target>
> >  <target name="rebuild" depends="rename"/>
> > </project>
> >
> > -Sanjeev
> >
> >
> >
> >
> > -----Original Message-----
> > From:   thilo boehm [mailto:thilo.boehm@gmail.com]
> > Sent:   Tue 8/10/2004 11:10 AM
> > To:     user@ant.apache.org
> > Cc:
> > Subject:        rename file with mapper
> > Hello everbody,
> >
> > I am trying to rename some files with ANT 1.6.1 using the a matcher.
> >
> > LIVE_filename.txt should be filename.txt
> >
> > I tried:
> >
> >  <move todir="${dir}" >
> >    <fileset dir="${dir}">
> >      <include name="**/*"/>
> >    </fileset>
> >    <mapper type="glob" from="LIVE_*" to="*"/>
> >  </move>
> >
> > and
> >
> >  <move todir="${dir}" >
> >    <fileset dir="${dir}">
> >      <include name="**/*"/>
> >    </fileset>
> >    <mapper type="regexp" from="LIVE_(.*)" to="\1" />
> >  </move>
> >
> > without luck. Any help is appreciated.
> > It works, if the pattern is at the end of the filename, but not an the
> > beginning.
> >
> > Bye,
> >  Thilo
> >
> > --
> > - thilo boehm - www.tboehm.de - thilo/web/gmail -
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >
> >
> >
>
>
> --
> - thilo boehm - www.tboehm.de - thilo/web/gmail -
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message