Inspire EMEA 2022 On-Demand is live! Watch now, and be sure to save the date for Inspire 2023 in Las Vegas next May.
We'll be completing standard maintenance for our Single Sign-On system on November 30th 6pm Pacific Time for approximately one hour. During this time My Alteryx and sign-in functionality to all My Alteryx programs (Licensing Portal, Community, Beta Program, Case Portal, and others) may be inaccessible. Thank you for your patience.

Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer and Intelligence Suite.
SOLVED

Change directory level (effectively DOS cd ..)

YeahMan
8 - Asteroid

Hi,

 

I have source data in a directory structured like C:\2020-21\Source Data\BHE

Using the Directory Tool I have the path stored in the directory variable [Directory]

I want to store the output in C:\2020-21 (up 2 levels)

Is there anyway to perform something similar to the DOS command "cd ..\.." to get to C:\2020-21?

 

I am currently using the Substring function to hard-code it, but there has to be a more elegant solution. I've looked at the 'Run Command' tool, but even that seems like overkill. Any suggestions would be appreciated.

 

Thanks,

--sue

6 REPLIES 6
Luke_C
17 - Castor

Hi @YeahMan 

 

Sounds like you may want to use a relative path in your output:

 

https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/How-To-Use-Relative-Paths/ta-p/1160

 

binuacs
17 - Castor

@YeahMan Looking for something like this?

Spoiler
ReverseString(SubString(SubString(TrimLeft(ReverseString([Directory]),"\"),FindString(TrimLeft(ReverseString([Directory]),"\"),"\")+1,Length([Directory])),FindString(SubString(TrimLeft(ReverseString([Directory]),"\"),FindString(TrimLeft(ReverseString([Directory]),"\"),"\")+1,Length([Directory])),"\")+1,Length([Directory])))

 

Spoiler
binuacs_0-1640277069365.png

 

YeahMan
8 - Asteroid

Thanks @binuacs . That works, but dang it's ugly 😁. I'm going to see if I can construct a regex solution.

binuacs
17 - Castor

@YeahMan RegEx 

 

REGEX_Replace([Directory], "((.*)\\\w+)\\\w+", "$2")

 

Spoiler
binuacs_0-1640278030607.png

 

YeahMan
8 - Asteroid

Thanks @binuacs for the regex. It got me close! I ended up using the following:

 

REGEX_Replace([Directory],'[\s*[a-z A-Z 0-9]+\\\s*[a-z A-Z 0-9]+\\]*$', '')

 

as it gives me a little more flexibility in the directory names.

YeahMan
8 - Asteroid

Thanks @Luke_C  for the suggestion. I didn't end up using it for this purpose, but I used it for something else.

Labels