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

Community site session details

Session Id : 6jqdFNuoBPE8+nkB8cK/cH
Power Automate - Building Flows
Answered

Removing File Extension

Like (0) ShareShare
ReportReport
Posted on 2 Sep 2020 22:00:22 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

I have the same question (0)
  • Verified answer
    Erica0214 Profile Picture
    on 03 Sep 2020 at 06:08:37
    Re: Removing File Extension

    @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 03 Sep 2020 at 13:05:29
    Re: Removing File Extension

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

  • Suggested answer
    TomislavTasic Profile Picture
    8 on 14 May 2025 at 14:09:59
    Removing File Extension
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 666 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 382 Moderator

#3
developerAJ Profile Picture

developerAJ 254

Last 30 days Overall leaderboard
Loading started
Loading complete