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 / Changing a file name i...
Power Automate
Unanswered

Changing a file name in sharepoint

(0) ShareShare
ReportReport
Posted on by 133

Hello again!

Trying to create a flow where paper documents are scanned in, their contents saved to SharePoint and the files are named with a shipment number contained on the paper documents. 

The scanner sends the scan to an email address which triggers a flow that saves the attachment to sharepoint.

I have a second flow that is triggered when a document is created in the sharepoint folder. An AI model that extracts a shipment number form the scan image.

The bit I'm stuck on is I now want to rename the scan document to be the same as the shipment number. I have tried using the create file and copy file options but havnt had much luck.  
When I did the create file option - it created a file successfully with the shipment number as the name, but it was just a blank file.
When Im trying the copy file, I can figure out how to change the name.

(The teams message is just for testing so that I knew the AI bit was working)

adrianm_0-1647013897911.png

 





Categories:
I have the same question (0)
  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @adrian-m 

    Essentially, you'll need to create a new file with the new name and delete the original when you're done.

    Here is a link to a blog post that explains all but the delete.

    The problem that you'll have is that you'll create an infinite loop - the Flow will run again when the new file is created.   You might add a condition that says of the file was created by you, then exit the Flow to work around this issue.

     

  • Ellis Karim Profile Picture
    11,681 Super User 2025 Season 2 on at

    Here is another method which uses the file check out and check in actions:

    Renaming a SharePoint file using REST API with Power Automate

     


    Ellis
    ____________________________________
    If I have answered your question, please mark the post as Solved.
    If you like my response, please give it a Thumbs Up.

  • adrian-m Profile Picture
    133 on at

    thanks for the reply, in the get file content action - which file identifier should i use? (Im not sure this method will even work - it wants me to specify a single existing document rather than anyway to get it to dynamically do it for files in a folder)

    New files may come in quickly - the users stand at tray fed scanner and just pour orders in, one email/pdf will be created per order but they might do 20 orders one after another. So PDF's might stack up in the folder - Cant have the flow relying on there only being a single document in the folder to work. 
    When a document is created - we need to specifically identify that document that was just created regardless of what else is in the folder.

    adrianm_0-1647095389847.png

     

  • Ellis Karim Profile Picture
    11,681 Super User 2025 Season 2 on at

    Try using one of the When a file is created triggers, for example:

    Snag_f7f1d2d.png

    Ellis

  • adrian-m Profile Picture
    133 on at

    seems like i need two triggers? When a File is created (properties only) - to get the file ID and "When a file is created" in order to get the file contents.

    However when I try to use two triggers teh flow just stalls on the second trigger 😞 (i assume you cant have 2 in the same flow?)

  • Ellis Karim Profile Picture
    11,681 Super User 2025 Season 2 on at

    The flow should only use one trigger. Start with a simple flow, using the When a File is created (properties only) trigger, then get the file content using path for use in your AI builder action.

     

    Ellis

  • adrian-m Profile Picture
    133 on at

    file contents doesnt seem to be an option from the AI model action. 

    Also, it seems the AI model action wont work with the Properties only "when a file is created" - it cant get the file contents to work on

  • Ellis Karim Profile Picture
    11,681 Super User 2025 Season 2 on at

    Can you try something like this?

    Snag_149f18e9.png

    Ellis

  • JoeF-MSFT Profile Picture
    on at

    Nice use case for AI Builder @adrian-m!

     

    Here is an example flow of how this can be achieved. Here I'm using the extracted value 'Sales order number value' returned by the AI Builder model as the new name of the file.

     

    JoeFMSFT_0-1647184263816.png

     

    The following link explains in more details the Send an HTTP request to SharePoint action: Rename a file in SharePoint with a single Power Automate action (tomriha.com)

  • adrian-m Profile Picture
    133 on at

    Thanks for the reply....I am getting an error on the http request -


    {
      "status"404,
      "message""List 'Documents/Shared Documents/Inbound Files' does not exist at site with URL 'https://company.sharepoint.com/sites/SBTransport528'.\r\nclientRequestId: 1aedddc2-bb9b-48cd-b074-fdf1e5025953\r\nserviceRequestId: 799f29a0-608e-3000-ec2a-ba1888d3e6c6",
      "errors": [
        "-1",
        "System.ArgumentException"
      ]
    }



    and yet it can find that location just fine with the trigger and when creating the file at the beginning etc

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

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard