Page 1 of 1

how do I strip folders grandparents?

Posted: 09 Aug 2011 20:37
by tiago
Hi.

Is there a method so I can grab the folder's "grandparent", on <curpath>?

Code: Select all

curpath:
C:\Arquivos de programas\microsoft frontpage\version3.0\bin

target:
C:\Arquivos de programas\microsoft frontpage\version3.0\

**
cp:
C:\Arquivos de programas\CONEXANT\CNXT_MODEM_PCI_VEN_14F1&DEV_2F50&SUBSYS_205F14F1

t:
C:\Arquivos de programas\CONEXANT\

**
cp:
C:\Arquivos de programas\acv315\removedcache\iconcache

t:
C:\Arquivos de programas\acv315\removedcache\
Thanks.

Re: how do I strip folders grandparents?

Posted: 09 Aug 2011 20:57
by highend
You could use e.g. a regexreplace like:

Code: Select all

$grandparent = regexreplace("<curpath>", "(.*(?=\\.*)\\)(.*)", "$1");

text $grandparent;
Not very elegant but it does it's job.

Re: how do I strip folders grandparents?

Posted: 09 Aug 2011 21:11
by tiago
That's perfect highend, thanks a lot!