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 / change file extension ...
Power Automate
Unanswered

change file extension with power automate

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Is it possible to change an existing file's extension in a SP document library?  I have seen many example on renaming the file's name but not the actual extension.  For example is a file's name is file.html can i change it to file.aspx without having to create a new file and deleting the old one?  Thanks!

Categories:
I have the same question (2)
  • GeorgiosG Profile Picture
    1,013 Super User 2024 Season 1 on at

    Hi @Anonymous ,

     

    I am not aware of an action for simply changing the file type with one action in Power Automate. you can Create a new file with the content and just pass in file name the new format with a concat() function. You can use directly Name with .xlsx like in my screenshot or use an expression 

    concat(FileName,‘.docx‘)


    CCCD9200-4071-4A16-9A61-029A03430BBD.jpeg

    A57EBFB1-51CC-4BEA-91CB-68210F8093AE.jpeg

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you your response, I was aware of this but i was looking to retain the document id and not have to create a new one and delete the old file.

  • GeorgiosG Profile Picture
    1,013 Super User 2024 Season 1 on at

    Maybe you can use the SharePoint API with the Send HTTP Request to SharePoint action.

    maybe you can go with that approach 

     

    B4248E03-8B91-4408-ADF5-533A87846290.jpeg

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I tried this and got the flow to work however, it is not working as we expect.  If the file already stored in the library is <FileName.aspx> and i want to change it to <NewFile.txt> the flow will run successfully but it only changes the file's name not the extension.  I end up getting NewFile.html

  • GeorgiosG Profile Picture
    1,013 Super User 2024 Season 1 on at

    Are you also passing in the extensions ? 

    I made a quick research and also found that it Wald solved with another api endpoint, maybe that helps https://powerusers.microsoft.com/t5/General-Power-Automate/Renaming-SharePoint-file-using-REST-API-with-Power-Automate-cuts/td-p/853435

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Yes i am passing the filename and extension within the body liek below.  I even tried the new endpoint and it doesnt not change the actual extension.

     

     

    {
    "formValues":[
    {
    "FieldName":"FileLeafRef",
    "FieldValue":"Filename.txt"
    }
    ]
    }

    skarthanal_0-1650638384048.png

     

  • farsamigmail Profile Picture
    30 on at

    Hi,

     

    Is there any solution for changing file extensions?

     

    Thank you

  • spoofan Profile Picture
    4 on at

    It is not working anymore. I ended up by creating a new file, setting up the properties and deleting the old one.

  • lroade Profile Picture
    2 on at

    Hello Spoofan, 

     

    How did you set up the properties? I have deleted the old one and created a new one named .xlsm and it wont open because it says the extension does not match.

     

    Could you send screenshow of your flow? thanks!

     

    2023-05-22_11h21_22.png

  • SemiAwakeNic Profile Picture
    2 on at
    Not sure if it's against the rules to post AI answer, but this answer by Copilot worked for me.
     
     

    You can indeed use HTTP requests in Power Automate to change a file extension on SharePoint. Here's a step-by-step guide on how to do it:

     

    1. Trigger: Start with a trigger that suits your needs, such as "When a file is created or modified" in a SharePoint library.


    2. Send an HTTP request to SharePoint:

       

      • Site Address: Your SharePoint site URL.

      • Method: POST.

      • URI: _api/web/GetFileByServerRelativeUrl('/sites/YourSite/Shared Documents/YourFileName.old')/moveto(newurl='/sites/YourSite/Shared Documents/YourFileName.new',flags=1)

      • Headers:
        json
        {
        "Accept": "application/json;odata=verbose",
        "Content-Type": "application/json;odata=verbose"
        }


    3.  
     

    This HTTP request uses the moveto method to rename the file, effectively changing its extension[1][2].

     

    Here's a more detailed breakdown:

     

    1. Trigger: Choose a trigger that fits your scenario, such as "When a file is created or modified".


    2. Send an HTTP request to SharePoint:

       

      • Site Address: Enter your SharePoint site URL.

      • Method: Select POST.

      • URI: Use the following format:
       
       _api/web/GetFileByServerRelativeUrl('/sites/YourSite/Shared Documents/YourFileName.old')/moveto(newurl='/sites/YourSite/Shared Documents/YourFileName.new',flags=1)
      
       

      Replace YourSite, YourFileName.old, and YourFileName.new with your actual site name and file names.


    3. Headers: Add the following headers:



    4.  
     
       {
         "Accept": "application/json;odata=verbose",
         "Content-Type": "application/json;odata=verbose"
       }
    
     

    This method allows you to rename the file, effectively changing its extension without needing to download and re-upload the file.

     

    Would you like more details on any of these steps or help with setting up the flow?


    References

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 608

#2
Valantis Profile Picture

Valantis 416

#3
11manish Profile Picture

11manish 348

Last 30 days Overall leaderboard