Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

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

 





  • JoeF-MSFT Profile Picture
    on at
    Re: Changing a file name in sharepoint

    Thanks @reidb - instead of using 'ItemId' I think we need to use another identifier. Try with ID or Identifier outputs from SharePoint instead. 

  • reidb Profile Picture
    7 on at
    Re: Changing a file name in sharepoint

    Joe, i tried using the root documents folder, and still no joy.  Flow sees file drop, gets ID and passes to HTTP POST request. Test Flow completed successfully.

    Here are the raw outputs of the HTTP request:

     

    reidb_0-1672756805416.png

     

  • reidb Profile Picture
    7 on at
    Re: Changing a file name in sharepoint

    Joe,

    I just tried the root of documents, and still no success, but the flow tested successfully.  It is seeing the file drop, getting the ID, and passing to the HTTP request, but never writing out the new xlsx file from the source csv.

     

    reidb_0-1672755611501.png

     

  • JoeF-MSFT Profile Picture
    on at
    Re: Changing a file name in sharepoint

    Hi @reidb - what you should put in the URI is the name of the document library. By default in many cases is Documents. Here is where you see it in SharePoint:

     

    JoeFMSFT_0-1672498153571.png

     

    Have you tried with: _api/web/lists/GetByTitle('Documents')/items(<PUT YOUR FILE ID HERE>)/validateUpdateListItem 

     

    Happy new year! 🎇

  • reidb Profile Picture
    7 on at
    Re: Changing a file name in sharepoint

    I am getting an error in "Send HTTP Request" step where the file cannot be found.

    My files are actually in a subfolder of "Documents" called TermList

    Both Trigger and GET file Metadata work fine to ID the actual file.

     

    All i need to accomplish is to rename the file from xyz.csv to xyz.xlsx - change filetype.

     

    I have tried several iterations of the folder structure in the uri 

    GetByTitle('Documents/TermList')/items

    ... ('Shared Documents/TermList')/items

    neither work..

    reidb_0-1672355479102.png

    error: (with a different file path, but get same error no matter what path i put in)

    reidb_1-1672355549219.png

     

  • Ellis Karim Profile Picture
    10,912 Super User 2025 Season 1 on at
    Re: Changing a file name in sharepoint

    Power Automate now has a new function called slice. See: Reference guide for expression functions - Azure Logic Apps | Microsoft Docs

    Example:

    ekarim2020_0-1648024818646.png

    slice('4000789654',4) returns 789654
     
    Hope this helps.
     
    Ellis
     
     
  • adrian-m Profile Picture
    133 on at
    Re: Changing a file name in sharepoint

    thats worked perfectly thanks!!!

  • Verified answer
    JoeF-MSFT Profile Picture
    on at
    Re: Changing a file name in sharepoint

    Hi @adrian-m - more like this, using the Expression menu. 

     

    expression3.gif

  • adrian-m Profile Picture
    133 on at
    Re: Changing a file name in sharepoint

    like this?

    adrianm_0-1647944555156.png

     

  • JoeF-MSFT Profile Picture
    on at
    Re: Changing a file name in sharepoint

    Hi @adrian-m - congrats on successfully building this automation! 🙂

     

    Apologies for taking some time to response to your last question. The following expression should take care of truncating the first four digits:

     

    substring(Put here the shipping number output, 4, sub(length(Put here the shipping number output), 4))

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 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow