web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Get File Extension/Mic...
Power Automate
Answered

Get File Extension/Microsoft Forms upload file to Sharepoint and rename file

(0) ShareShare
ReportReport
Posted on by 8

I am creating a flow to take a file uploaded to Microsoft Forms and move the file to SharePoint.
As the file is moved to sharepoint, it will be renamed using the answers on the form where the file was uploaded. 

I am able to move and rename the file using the answers but I am stuck when I try to add the file extension on the end, as it may be a different file type depending on the uploaded file.

So far it goes like this:

Dan2023_0-1696446950165.png

When a new response is submitted:
Form id: (Selected form)

 

Get Response Details:
Form id: (Selected form)

Response ID: Response Id (dynamic content)

 

List files in folder(OneDrive):

/Apps/Microsoft Forms/(Selected form)/Upload

At this point I was going to use an Apply to each to take the Value from the OneDrive file and use 'Compose' step to take the input Name(OneDrive) and have it output the name. Then 'Compose 2' step to separate the name from the extension and leave me with just the extension to use later on.

Dan2023_1-1696447411422.png

Compose:
Input: Name(OneDrive)

Compose 2:

input: Expression:   last(split(triggerOutputs()?['body/Name'], '.'))      <-----this expression doesn't properly output anything

 

The extension would be used when creating the file name in the next part

Dan2023_2-1696447483616.png

Apply to each:
(select an output from previous steps)
Value(OneDrive)

Get File content:

File: Id(OneDrive)

 

Create File:
Site Address: (Sharepoint site)

Folder path: (folder location where the file will be dropped)

File name: (Form Answer1)-(Answer 2).(output Compose2) <--- this is where the issue is

File Content: Body(OneDrive)

Delete File:
File: Id(OneDrive)


I originally added the "Media Type(OneDrive)" Dynamic content but it returns the type of media and extension.
Example: .application_pdf

 

Categories:
I have the same question (0)
  • Verified answer
    Pstork1 Profile Picture
    69,110 Most Valuable Professional on at

    The file that is uploaded has a filename with extension already. You can use Split() on a '.' and Last to get the file extension of the existing file and then concatenate that to the new filename you want to use to rename the file when you create it.

  • Dan2023 Profile Picture
    8 on at

    Thank you. I am sure you were talking about something a little more elegant, but I removed 'apply to each 2' and added the 'Compose' and 'Compose 2' to just after 'Get file content'. 


    In compose 2 I used the expression:   Last(Split(outputs('Compose'),'.'))

    Then added the Compose 2 output dynamic content to the end of the file name: 
    FormAnswer1-FormAnswer2.Compose2Outputs 

    Dan2023_0-1696510460801.png

    Your answer helped a lot with my understanding! Much appriciated!



  • Pstork1 Profile Picture
    69,110 Most Valuable Professional on at

    You could do it in one, but that's essentially what I was suggesting.

  • Dan2023 Profile Picture
    8 on at

    Thank you, I will play around with it and try that out.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 557

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 264 Super User 2026 Season 1

Last 30 days Overall leaderboard