Alteryx Designer Desktop Discussions

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

Extracting file name from customized path

User12
7 - Meteor

Hello everyone!

 

I have a list of paths that lead to exact sheet, but I need only File name.

I suppose it should be a solution via RegEx ( I don't know how to use this tool properly)

Formula tool is not working well in my example (Filegetfilename).

 

Could you, please, provide me with the suitable expression? 

 

Workflow with the data attached below.

 

Thanks in advance!

13 REPLIES 13
ShankerV
17 - Castor

hi @User12 

 

Please let me know what is the expected output.

 

I see only the input in the attached workflow. Sharing the expected output will help to work on the solution.

 

 

binuacs
20 - Arcturus

@User12 One way of doing this with the Regex_Replace formula

 

binuacs_0-1670943614386.png

 

User12
7 - Meteor

Hi!

I hope to get the next output:

 

18.7.
18.7.
18.8+
18.9_
ShankerV
17 - Castor

@User12 

 

Does filename you are expecting is "18.7..xlsx" or "18.7."

 

JamesCharnley
13 - Pulsar

Hi @User12,

 

FileGetFileName returns the name portion of the file without the extension. It's essentially taking everything from the last '\' to the next '.', signifying the start of the extension. When I use it on your input, it's working as expected with the output that you want:

 

JamesCharnley_0-1670943725135.png

Is there some reason this doesn't work for your file names? It should be pretty robust

binuacs
20 - Arcturus

@User12 if you don't want the extension then update the formula like below

 

binuacs_0-1670943774523.png

 

User12
7 - Meteor

That's exactly what I need! Thank you!

But, could you, please, provide me with the expression (I don't really understand exact signs that you are using), that i can copy&paste into my formula tool?
It would be very helpful.

ShankerV
17 - Castor

Hi @User12 

 

Please find the expected output via Regex as expected.

 

.*\\(.*).\l{4}\|\|\|.*

 

Breaking down the Regex formula built to arrive the solution, 

we have a unique pattern in the Input.

Hence .*\\ will help to eliminate the characters in the front.

The regex tool will create a new column only for the data inside the () open and close paranthesis

Hence I am reading (.*) where it will read all the characters . denotes any charater and * denotes n number 

.\l denotes small a-z and when it finds .xlsx it stops reading the filename.

 

ShankerV_0-1670944566006.png

 

hope this helps!!!!

 

ShankerV
17 - Castor

@User12 

 

If you are new to Regex, you can make use of link https://regex101.com which will be more helpful to you.

 

 

 

Labels