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 / Renaming heaps of Shar...
Power Automate
Answered

Renaming heaps of SharePoint files within folders

(0) ShareShare
ReportReport
Posted on by 97

I am building a flow and have got stuck with the renaming criteria for the files that live in a SharePoint Online document library.

 

The flow would be a one time run covering for each of the files in the document library (which contains folders and files in the folders). I only want the .pdfs to be updated.

 

The error I get is on the http action is:

 

Unable to process template language expressions in action 'Send_an_HTTP_request_to_SharePoint' inputs at line '0' and column '0': 'The template language function 'split' expects its first parameter to be of type string. The provided value is of type 'Array'.

 

I have search the web for a while but cannot get to the bottom of the error. I have tried variables but still get the type string v array error.

 

The current format of the files is:   1234_Fred_Smith.pdf

 

I need the name of the files to be in the format of:  1234_Smith_Fred.pdf

 

I used the split function but this causes it to error. 

 

Any assistance with this would be much appreciated.

 

eddoria_0-1665724057619.png

 
 
 

 

eddoria_6-1665724243253.png

 

 

 

 

 

Categories:
I have the same question (0)
  • eddoria01 Profile Picture
    97 on at

    Thinking about this and using http, is it possible to just use update the field name and not send a http request. I am not sure when we need to use update file properties or send a http request.

  • grantjenkins Profile Picture
    11,063 Moderator on at

    The logic that I would follow is below:

    1. Get files (PDF files only)
    2. For each file
      1. Split the current name by underscore
      2. Convert to get new name using array items, underscores, and .pdf
      3. Rename file

    I would probably also add in some checking to confirm the split function results in 3 items, but depends on whether you're sure the current naming convention is in the format 1234_FirstName_LastName for all PDFs.

     

    I would also highly recommend you try this in a test environment first to ensure it works as expected, and if possible have a backup of the library you're running this across. Without knowing how many files you have, naming, etc. it's important that you weigh up the risks before running.

     

    Below is the folder/file structure I used for the example:

    grantjenkins_5-1665736555222.png

    grantjenkins_6-1665736583300.png

     

    And the result after running the flow:

    grantjenkins_7-1665736613855.png

    grantjenkins_8-1665736633836.png

     

    Overview of the flow is below (more detail of each action below):

    grantjenkins_0-1665735571976.png

     

    Get files (properties only)

    I have a Filter Query to only bring back files (not folders) and only PDF files. I also set Include Nested Items to Yes.

    FSObjType eq 0 and File_x0020_Type eq 'pdf'

    grantjenkins_1-1665735760426.png

     

    Compose - Split Name

    This splits the current name by underscore which should result in an array with 3 items:

    split(item()?['{Name}'],'_')

    grantjenkins_2-1665735874225.png

     

    Compose - New Name

    This combines the array items from the split expression.

    concat(outputs('Compose_-_Split_Name')[0],'_',outputs('Compose_-_Split_Name')[2],'_',outputs('Compose_-_Split_Name')[1],'.pdf')

    grantjenkins_3-1665735960564.png

     

    Send an HTTP request to SharePoint

    This renames each file using the output from the Compose - New Name action

    Note that the /validateUpdateListItem will ensure that your file version won't be affected by the rename.

    Note that you will need to specify the Title of your actual Library in place of Documents below.

     

    _api/lists/GetByTitle('Documents')/items(@{items('Apply_to_each')?['ID']})/validateUpdateListItem
    {
     "formValues":[
    	{
    	 "FieldName": "FileLeafRef",
    	 "FieldValue": "@{outputs('Compose_-_New_Name')}"
    	}
     ]
    }

    grantjenkins_4-1665736053641.png

     

  • Verified answer
    eddoria01 Profile Picture
    97 on at

    Hi Grant, thank you so much for the indepth info. Very much appreciated. I have implemented your suggestions to a test site with only sample records (just in case!!!).

     

    The workflow failed again with the string v array error.

    eddoria_0-1665737485264.png

    This is what I have in the compose action

    eddoria_1-1665737544485.png

     

  • eddoria01 Profile Picture
    97 on at

    I have updated my flow as per your screen shots. Apologies but I was reading from the text. I will give it another go.

  • eddoria01 Profile Picture
    97 on at

    I have go further thanks. However it is failing on the Send an HTTP action. The compose actions are correct.

    Error received: Item does not exist. It may have been deleted by another user.
    clientRequestId: 26c9c73f-4c9a-4eb2-8ae7-9efac409e009
    serviceRequestId: d77e6ea0-f0c1-1000-bf80-542c71de4461

     

    From the Uri I can see the ID of the files in the document library. My workflow knowledge is not great and I guess that the action would take ID 6 and rename it. There is an ID 6 but it still fails.

    eddoria_0-1665738974771.png

     

  • grantjenkins Profile Picture
    11,063 Moderator on at

    Looks like you still need to change the library name in the HTTP request. It's currently set as Documents but should be the title of your library - HRPayrollTest from what your initial screenshot had.

  • eddoria01 Profile Picture
    97 on at

    Doh!! Updated to my library name and it works. Thank you so much.

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!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 77 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 68

#3
Expiscornovus Profile Picture

Expiscornovus 56 Most Valuable Professional

Last 30 days Overall leaderboard