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

change file extension with power automate

(0) ShareShare
ReportReport
Posted on by

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
    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
    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
    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

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard