Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop 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
20 - Arcturus

@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
20 - Arcturus

@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