Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

Extract File Name from File Directory

SH_94
11 - Bolide

Dear Community,

 

May i know how can i extract the file name from the file directory as below:

 

Directory examples

1.C:\Users\XXXX\Desktop\Alteryx\ABC\UDJD Input.csv

2.C:\Users\XXXX\Desktop\Alteryx\ABC\URKELC\XJX1828.csv

3.C:\Users\XXXX\Desktop\Alteryx\ABC\5324.csv

4.C:\Users\XXXX\Desktop\Alteryx\BD\92.csv

5.C:\Users\XXXX\Desktop\BD33\1nbfi.csv

 

Results wanted

1.UDJD Input

2. XJX1828

3.5324

4.92

5.1nbfi

 

Many thanks for your help

 

5 REPLIES 5
fmvizcaino
17 - Castor
17 - Castor

Hey @SH_94 ,

 

We can use regex to get that filename.

If you want to learn more about regex: https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/Tool-Mastery-RegEx/ta-p/37689

fmvizcaino_0-1628131514432.png

 

Best,

Fernando Vizcaino

HomesickSurfer
12 - Quasar

Hi @SH_94 

 

Either of two simple formulas:

 

FileGetFileName([FullPath])

 

FileGetFileName([FileName])

atcodedog05
22 - Nova
22 - Nova

Hi @HomesickSurfer 

 

Mindblown 😮 where did you come across this. This works amazingly for this scenario.

 

Workflow:

atcodedog05_0-1628177158269.png

 

Thank you for this knowledge share 🙂 @HomesickSurfer 

 

HomesickSurfer
12 - Quasar

Thank you @atcodedog05 

 

I make good use of the various 'GET' functions.  They're efficient.

 

@SH_94 , you may wish to additionally filter to exclude backups, temp files, etc as follows, or config your file specification in the Directory tool to only include filetypes you seek.

 

FileGetExt([FullPath])!=".bak" OR "~$"

atcodedog05
22 - Nova
22 - Nova

Definitely bookmarking this post. So much knowledgable 😀

 

Thank you @HomesickSurfer 

Labels
Top Solution Authors