cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
agour
Frequent Visitor

Extracting file name and using within flow

Hello!

 


I have a flow where I wish to extract the filename of the file, but without the extension.

 

So if it was "somepicture.jpg", I want to use "somepicture" in the HTTP post later on.

 

My flow looks like this:

flow.jpg

 

I have spent a lot of time trying to get this to work, and have tried multiple options for extracting the filename.

 

I am sure that I must be close.. but I can't quite figure it out.

 

Any ideas? I'm happy to do it another way, just as long as it works.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
agour
Frequent Visitor

Fixed it!

 

I don't know why - but using the dynamic expression for 'filename' always gives a garbled end result.

 

The only way to do it, was to initialise the variable first, and then later use it.

 

 

flow3.jpg

View solution in original post

8 REPLIES 8
v-yamao-msft
Community Support
Community Support

Hi @agour,

 

To extract the file name of the file without the extension, please try to combine functions split and first.

 

You could use the following code:

first(split(triggerOutputs()['headers']['x-ms-file-name-encoded'],'.'))

 

Then you could use the output from the Compose in the next action.

1.PNG

 

Please try it on your side.

 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Mabel,

 

I tried your suggestion, which makes sense to me.

 

The output from the compose action is a random string of charectors. Any idea what is going on?

 

flow.jpg

 

The actual filename was "McGoff_00018.jpg"

 

 

Thanks!

agour
Frequent Visitor

Bump - any further ideas? I still need to try and get this fixed

agour
Frequent Visitor

I have tried using Onedrive as the input, rather than ftp... and I still get the same issues.

 

I also tried using a replace function:

 

replace(triggerOutputs()['headers']['x-ms-file-name-encoded'], '.jpg', '')
 
And I still get the same strange string of charectors as the output..
agour
Frequent Visitor

Fixed it!

 

I don't know why - but using the dynamic expression for 'filename' always gives a garbled end result.

 

The only way to do it, was to initialise the variable first, and then later use it.

 

 

flow3.jpg

View solution in original post

SantoshBuddha
Advocate I
Advocate I

Using 

base64ToString should give you the correct Name.
base64ToString(triggerOutputs()?['headers/x-ms-file-name-encoded'])
Anonymous
Not applicable

That was my solution to get the name of my pdf file. Thanks! 

Thanks @SantoshBuddha , this worked!!!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (3,153)