Skip to main content

Notifications

Power Automate - Building Flows
Answered

Extract file extension and add to updated file name

(0) ShareShare
ReportReport
Posted on by 46

Morning everyone, 

 

I have a very complicated (probably more than it should be) flow that collects information from a Microsoft form, including two date fields and two uploaded documents.  It sends the documents off for approval and if approved, updates a microsoft list row with an updated date and saves the files into Onedrive with a new file name.  

 

 If I leave in the ParseJSON Name expression it brings over the extension of the file but the original name as well, making the new file name very long and disorganized. I am trying to clean up the naming function of the file.  I want to be sure the extension is added to the name but the original file name is removed.  I would like to make sure the just the extension is added in the File Name section of the Create File step. 

 

How do I go about getting the content type extension added to this file name?  Please see the pics below of the current flow.

 

bmcnal_0-1701113308775.pngbmcnal_1-1701113335993.pngbmcnal_2-1701113359951.png

bmcnal_3-1701113577780.png

 

 

 

  • bmcnal Profile Picture
    bmcnal 46 on at
    Extract file extension and add to updated file name
    Hello again @v-jefferni

    Just wanted to follow up on this fix.  Overall it works great, but occasionally people upload files that have multiple "." in the file name.  Resulting is error file creation. Is there a way to update the code below to only collect info after the last "." in the file name? 
    split(item()?['name'], '.')[1]
    Thanks for your time. 
     
     
  • Verified answer
    v-jefferni Profile Picture
    v-jefferni on at
    Re: Extract file extension and add to updated file name

    Hi @bmcnal ,

     

    This expression is used for replacing the extension directly in Create file action:

    vjefferni_2-1701223944617.png

     

    Best regards,

  • bmcnal Profile Picture
    bmcnal 46 on at
    Re: Extract file extension and add to updated file name

    I've tried your suggestion and get an error message.  I inserted the compose function as you have it written just under the Parse JSON but before the Apply to Each 4.  "'The template language function 'split' expects its first parameter to be of type string."  Looks like split needs a string input and it's not a string.  Thanks for your help. 

  • v-jefferni Profile Picture
    v-jefferni on at
    Re: Extract file extension and add to updated file name

    Hi @bmcnal ,

     

    You can use an expression to get the file extension only:

    split(item()?['name'], '.')[1]

     

    Best regards,

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,343

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,703

Leaderboard