Skip to main content

Notifications

Community site session details

Community site session details

Session Id : GpVMjDTPh0imrEx4D5ZeMz
Power Automate - Building Flows
Unanswered

change file extension with power automate

Like (0) ShareShare
ReportReport
Posted on 20 Apr 2022 17:36:28 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!

  • SemiAwakeNic Profile Picture
    2 on 29 Nov 2024 at 18:54:58
    change file extension with power automate
    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
  • lroade Profile Picture
    2 on 22 May 2023 at 15:23:16
    Re: change file extension with power automate

    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

  • spoofan Profile Picture
    4 on 19 Apr 2023 at 08:55:56
    Re: change file extension with power automate

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

  • farsamigmail Profile Picture
    30 on 15 Sep 2022 at 14:51:14
    Re: change file extension with power automate

    Hi,

     

    Is there any solution for changing file extensions?

     

    Thank you

  • Community Power Platform Member Profile Picture
    on 22 Apr 2022 at 14:40:12
    Re: change file extension with power automate

    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

     

  • GeorgiosG Profile Picture
    1,013 Super User 2024 Season 1 on 22 Apr 2022 at 14:18:30
    Re: change file extension with power automate

    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 22 Apr 2022 at 13:58:42
    Re: change file extension with power automate

    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 20 Apr 2022 at 18:54:24
    Re: change file extension with power automate

    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 20 Apr 2022 at 18:45:04
    Re: change file extension with power automate

    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 20 Apr 2022 at 17:59:30
    Re: change file extension with power automate

    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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 97

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 82 Super User 2025 Season 1

#3
David_MA Profile Picture

David_MA 48 Super User 2025 Season 1

Overall leaderboard