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 / Insert fields to autom...
Power Automate
Suggested Answer

Insert fields to automatically update file/folder names

(0) ShareShare
ReportReport
Posted on by 2
Within SharePoint, can you insert a field in the name of a folder so that when you copy that folder, it automatically updates the folder name and the file names within that folder?
 
For example, I currently have a templated folder for new hires titled "TEMPLATE - Development Center Folder" and within that folder are docs titled "TEMPLATE - Onboarding Schedule", "TEMPLATE - New Hire Checklist", and "TEMPLATE - Performance Notes". 
When I duplicate the templated folder, I have to manually rename the folder and every file within it (e.g., "Joe Smith - Development Center Folder", "Joe Smith - Onboarding Schedule", etc.).
 
 
Categories:
I have the same question (0)
  • Suggested answer
    harshdeol Profile Picture
    619 Super User 2026 Season 1 on at
    Hi @LP-30122100-0,
    As far as I know, SharePoint itself doesn’t support dynamic fields in folder or file names.But this can be achieved using Power Automate. You need to create a Power automate flow.
    This is a most common use case in the Organization so let me share the detailed Power Automate Flow to automate this setup. For this, I have created one at my end.

    //Assumptions
    I am assuming that within SharePoint Document Library you have a folder where current TEMPLATE folder is Stored.
    and You copy that Folder to different Folder (Same Document Library of Different Document library). I am using different document libraries in this case. You can modify the Flow/File path based on your specify Setup and requirement.

    Instead of Copying folder directly from SharePoint document Library, you can now Copy the Folder using this Flow automatically. You just need to run the Power Automate flow and It willl ask for the Employee Name. Once ran successfully, It will automatically copy the folder and Files (After Renaming) 

    If you want you can change the Power Automate Flow and trigger and other things as needed.

    //Setup
    1. Where TEMPLATE Folder is Saved
    SharePoint Site Name:
    Community
    Document Library Name: Documents
    Folder Name: TEMPLATE - Development Center Folder
    Under that I have several Files. See attached Image

    2. Where I am copying the document below:
    SharePoint Site Name: Community
    Document Library Name: Document Library 2


    //Power Automate Flow
    1. Trigger: Manually trigger a Flow

    I have created the power Automate flow with Manual Trigger and set a Input Parameter as Employee Name.

    2. Action: Copy Folder
    Add your current and Destination SharePoint Site (Add same if both folder are in the same SharePoint site). Also, Select the Folder Path.
    This will copy your Templatate folder.

    3. Get Files(Properties Only)
    This is used to Get all the files of Newly create TEMPLATE folder. 

    4. Send and HTTP request to SharePoint
    This is added to Rename the Main TEMPLATE Folder.

    URI: _api/web/lists/GetbyTitle('Document Library 2')/items(@{outputs('Copy_folder')?['body/ItemId']})/validateUpdateListItem
    Body: 
    {
      "formValues": [
        {
          "FieldName": "FileLeafRef",
          "FieldValue": "@{triggerBody()['text']}@{replace(outputs('Copy_folder')?['body/Name'], 'TEMPLATE','')}"
        }
      ]
    }


    * In the URI's GetbyTitle replace 'Document Library 2' with your document Library Name.
    **Rename Logic: Employee Name + Replace the TEMPLATE with '' (Empty String). You can use the split() as well.


    5. Add an Apply to each to iterate on each files of that Folder.
    6. Send an HTTP request to SharePoint
    Added this action again to rename the Files

    URI: _api/web/lists/GetbyTitle('Document Library 2')/items(@{items('Apply_to_each')?['ID']})/validateUpdateListItem
    Body: 
    {
      "formValues": [
        {
          "FieldName": "FileLeafRef",
          "FieldValue": "@{triggerBody()['text']}@{replace(outputs('Copy_folder')?['body/Name'], 'TEMPLATE','')}"
        }
      ]
    }


    * In the URI's GetbyTitle replace 'Document Library 2' with your document Library Name.
    **Rename Logic: Employee Name + Replace the TEMPLATE with '' (Empty String). You can use the split() as well.


    Now, the flow is Ready. Save this and Test.

    //Testing
    To test the flow, Click on the Test and Add Employee Name. I have added my name, this will rename the Template folder name and Replace TEMPLATE with Input name.
     

    //OUTPUT
    See the Renamed Folder is saved in the Document Library 2 and all the files is also renamed.
    In case if this folder have a Sub Folder and Files in that SubFolder then this current Power Automate flow will also rename that automatatically. You don't need seperate configuration for that. 
    Hope this helps. Please review and try this at your end. Let me know if you have any questions.
     
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If your question got an answer, accept this as Solution by selecting ✅ "Does this answer your question", If you liked my answer, please hit the ❤️(Like) button.

    Thank you,
    Harsh Deol
  • LP-30122100-0 Profile Picture
    2 on at
    Hi Harsh,
    Thank you so much for taking the time to walk through these steps!!
     
    For Step 6, the written instructions for Field Value differ from the screenshot.
    The written instructions say @{replace(outputs('Copy_folder')?['body/Name'], 'TEMPLATE','')}
    But the screenshot shows @{replace(items('Apply_to_each')?['{Name}'}, 'TEMPLATE',")}
     
    I tried both methods but neither changed the name of the files within the folder. 
     
    I noticed that the URI for Step 4 and 6 varied in your instructions so I tried a few different combinations in hopes that maybe that was the issue. I also tried @{replace(items('Apply_to_each')?['{body/Name}'}, 'TEMPLATE',")} and @replace(items('Apply_to_each')?['body/Name'], 'TEMPLATE','') with Step 6's URI, but it still didn't change the individual file names within the folder. 
     
    I'm not sure if this is a factor at all, but I'm not looking to copy the folder to a different library. I keep the "TEMPLATE - Development Center Folder" in the same location that I house other employees' populated Dev Center folders. 
     
    Please let me know if you see where I went wrong.
     

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!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 816

#2
Valantis Profile Picture

Valantis 603

#3
Haque Profile Picture

Haque 566

Last 30 days Overall leaderboard