You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Daniel Steinmann <ds...@acm.org> on 2009/09/07 13:28:54 UTC
Re: Delete N directories that match a regexp
Matt Benson wrote:
>
>
> (given same dirset id=ds)
> <pathconvert refid="ds" property="includes" pathsep="${line.separator}">
> <regexpmapper from="(^.*$)" to="\1${file.separator}**" />
> </pathconvert>
> <echo file="includesfile">${includes}</echo>
> <delete>
> <files includesfile="includesfile" />
> </delete>
> <delete file="includesfile" />
>
>
Great tip!
But I have problems with the to= part of the regex pattern on Windows. The
file.separator on Windows is the backslash, which is the escape character
for the regex. Therefore the file will include patterns like 'foo\bar**'
instead of 'foo\bar\**'. And then the delete does not work.
Do you have some more magic to make it work on Windows as well?
Thanks,
Daniel
--
View this message in context: http://www.nabble.com/Delete-N-directories-that-match-a-regexp-tp22727856p25328990.html
Sent from the Ant - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Delete N directories that match a regexp
Posted by Dominique Devienne <dd...@gmail.com>.
On Mon, Sep 7, 2009 at 6:28 AM, Daniel Steinmann<ds...@acm.org> wrote:
> Matt Benson wrote:
>> (given same dirset id=ds)
>> <pathconvert refid="ds" property="includes" pathsep="${line.separator}">
>> <regexpmapper from="(^.*$)" to="\1${file.separator}**" />
>> </pathconvert>
>> <echo file="includesfile">${includes}</echo>
>> <delete>
>> <files includesfile="includesfile" />
>> </delete>
>> <delete file="includesfile" />
> But I have problems with the to= part of the regex pattern on Windows. The
> file.separator on Windows is the backslash, which is the escape character
> for the regex. Therefore the file will include patterns like 'foo\bar**'
> instead of 'foo\bar\**'. And then the delete does not work.
Since one specifies filenames with forward slash only in a build file
(or property files),
and Ant does the right thing to convert them to the current OS, you
can tell <pathconvert>
to use / as the filesep, and use to="\1/**", then <files includes="">
should accept that. --DD
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Delete N directories that match a regexp
Posted by Francis GALIEGUE <fg...@one2team.com>.
On Mon, Sep 7, 2009 at 13:28, Daniel Steinmann<ds...@acm.org> wrote:
>
>
> Matt Benson wrote:
>>
>>
>> (given same dirset id=ds)
>> <pathconvert refid="ds" property="includes" pathsep="${line.separator}">
>> <regexpmapper from="(^.*$)" to="\1${file.separator}**" />
>> </pathconvert>
>> <echo file="includesfile">${includes}</echo>
>> <delete>
>> <files includesfile="includesfile" />
>> </delete>
>> <delete file="includesfile" />
>>
>>
>
> Great tip!
>
> But I have problems with the to= part of the regex pattern on Windows. The
> file.separator on Windows is the backslash, which is the escape character
> for the regex. Therefore the file will include patterns like 'foo\bar**'
> instead of 'foo\bar\**'. And then the delete does not work.
>
> Do you have some more magic to make it work on Windows as well?
>
There is WAY more simple:
<regexpmapper from="$" to="${file.separator}**" />
--
Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
fge@one2team.com
40 avenue Raymond Poincaré
75116 Paris
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Delete N directories that match a regexp
Posted by Daniel Steinmann <ds...@acm.org>.
Matt Benson wrote:
>
> It may be as simple as using / instead of file.separator. Give it a try!
>
Yes, this works.
Thank you,
Daniel
--
View this message in context: http://www.nabble.com/Delete-N-directories-that-match-a-regexp-tp22727856p25353970.html
Sent from the Ant - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Delete N directories that match a regexp
Posted by Matt Benson <gu...@yahoo.com>.
It may be as simple as using / instead of file.separator. Give it a try!
-Matt
--- On Mon, 9/7/09, Daniel Steinmann <ds...@acm.org> wrote:
> From: Daniel Steinmann <ds...@acm.org>
> Subject: Re: Delete N directories that match a regexp
> To: user@ant.apache.org
> Date: Monday, September 7, 2009, 6:28 AM
>
>
> Matt Benson wrote:
> >
> >
> > (given same dirset id=ds)
> > <pathconvert refid="ds"
> property="includes" pathsep="${line.separator}">
> > <regexpmapper from="(^.*$)"
> to="\1${file.separator}**" />
> > </pathconvert>
> > <echo
> file="includesfile">${includes}</echo>
> > <delete>
> > <files
> includesfile="includesfile" />
> > </delete>
> > <delete file="includesfile" />
> >
> >
>
> Great tip!
>
> But I have problems with the to= part of the regex pattern
> on Windows. The
> file.separator on Windows is the backslash, which is the
> escape character
> for the regex. Therefore the file will include patterns
> like 'foo\bar**'
> instead of 'foo\bar\**'. And then the delete does not
> work.
>
> Do you have some more magic to make it work on Windows as
> well?
>
> Thanks,
> Daniel
>
> --
> View this message in context: http://www.nabble.com/Delete-N-directories-that-match-a-regexp-tp22727856p25328990.html
> Sent from the Ant - Users mailing list archive at
> Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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