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
Regular Visitor

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
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,157)