how do I strip folders grandparents?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
tiago
Posts: 589
Joined: 14 Feb 2011 21:41

how do I strip folders grandparents?

Post 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.
Power-hungry user!!!

highend
Posts: 14954
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: how do I strip folders grandparents?

Post 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.
One of my scripts helped you out? Please donate via Paypal

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: how do I strip folders grandparents?

Post by tiago »

That's perfect highend, thanks a lot!
Power-hungry user!!!

Post Reply