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 / Removing File Extension
Power Automate
Answered

Removing File Extension

(0) ShareShare
ReportReport
Posted on by 3

Hi,

 

I have a flow right now that runs when an email attachment comes in, creates the file in a folder in OneDrive and appends the current date to the end of it. However when running the file it comes out as Test Flow.xlsx-MM-DD-YYYY.xlsx. How do I remove the .xlsx from the middle of the name?

 

What I have now for File Name is: [Attachment Name]-[utcNow('MM-dd-yyyy')].xslx

 

9-2-2020 5-57-02 PM.jpg

Categories:
I have the same question (0)
  • Verified answer
    Erica0214 Profile Picture
    on at

    @kkeirstead ,

     

    you could use the substring function to remove the extension.

     

    For example: 

     

    I have a variable 'name with extension' whose value is "Book.xlsx"

     

    substring(variables('name with extension'),0,sub(length(variables('name with extension')),5))
     
    the result of above function is Book.
     
    In your case, it could be :
     
    substring([Attachment Name],0,sub(length([Attachment Name]),5))-[utcNow('MM-dd-yyyy')].xslx
     

     

  • kkeirstead Profile Picture
    3 on at

    Thank you! It simplified my thought process quite a bit.

  • Suggested answer
    TomislavTasic Profile Picture
    8 on at
    You might have to work with files with different extension length (pdf, xls, doc, zip...).
    Let's assume we have would like to get the files without the Title, so we use HTTP call to get them:
    • Method: GET
    • Uri: _api/web/lists/getbytitle('Template Documents')/items?$select=Id,Title,ContentTypeId,FileLeafRef&$filter=Title eq null
    Afterwards we can use Compose step to get what we need using Expression:
    • From: body('HTTP_get_files_with_Title_equals_null')?['value']
    • Map (shown in the Code Snippet below):
    {
      "Id": item()?['Id'],
      "Name": item()?['FileLeafRef'],
      "ExtensionLenght": length(last(split(item()?['FileLeafRef'],'.'))),
      "Title": substring(item()?['FileLeafRef'],0,sub(length(item()?['FileLeafRef']),add(1,length(last(split(item()?['FileLeafRef'],'.'))))))
    }
    From the code above you can see the expression you were looking for is the one I have used finally to set the file Titles:
    • substring(item()?['FileLeafRef'],0,sub(length(item()?['FileLeafRef']),add(1,length(last(split(item()?['FileLeafRef'],'.'))))))
    Please check the images below.
     
    Flow steps
     
    Flow steps executed

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 589

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 284 Super User 2026 Season 1

Last 30 days Overall leaderboard