Skip to main content

Notifications

Community site session details

Community site session details

Session Id : Y9qU7DGjT9LTXk0XmuEThk
Power Automate - Building Flows
Answered

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

Like (0) ShareShare
ReportReport
Posted on 4 Oct 2023 19:49:47 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

 

  • Dan2023 Profile Picture
    8 on 05 Oct 2023 at 15:42:04
    Re: Get File Extension/Microsoft Forms upload file to Sharepoint and rename file

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

  • Pstork1 Profile Picture
    66,091 Most Valuable Professional on 05 Oct 2023 at 14:19:41
    Re: Get File Extension/Microsoft Forms upload file to Sharepoint and rename file

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

  • Dan2023 Profile Picture
    8 on 05 Oct 2023 at 12:55:10
    Re: Get File Extension/Microsoft Forms upload file to Sharepoint and rename file

    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!



  • Verified answer
    Pstork1 Profile Picture
    66,091 Most Valuable Professional on 04 Oct 2023 at 20:01:05
    Re: Get File Extension/Microsoft Forms upload file to Sharepoint and rename file

    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.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard
Loading started