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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Removing File Extension
Power Automate
Unanswered

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard