Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Suggested answer

Copy files containing unique IDs in the filenames to existing folders with the same ID in the name

(0) ShareShare
ReportReport
Posted on by 2
Hi. I've found several posts similar to my situation, but none close enough for me to be able to use, so I'm really hoping someone is able to help me out.

Situation:
  • I have a flow which creates a batch of folders in the root of a library on our SharePoint site, each with unique access permissions based off staff information in a list.
  • I also have a different library on the same SharePoint site which contains confidential Word documents relating to each staff member.
What I need:
  • A manually triggered flow that will create a copy of each Word document in the folder with the matching ID.

The file names are formatted: '<last name>, <first name>, <staff ID>, <document type>'
The folder names are formatted: '<last name>, first name (<staff ID>) '
 
So for example I need the flow to copy file 'Bloggs, Joe, 123456789, personal info.docx' into folder 'Bloggs, Joe (123456789)'.
 
Is there any way this can be done? I assume it will need to involve the split function and one or two arrays, but I'm not quite sure how.

Any help would be hugely appreciated!
  • Ever Reddy Profile Picture
    2 on at
    Copy files containing unique IDs in the filenames to existing folders with the same ID in the name
    @Meekou Thanks for your speedy reply, and my apologies if I'm missing something, but I'm relatively new to PA and it's my first time using the split function. I assume 'FileName' and 'Split_Path' in your example should be replaced with dynamic values, but I'm not quite sure which these should be?

    Could you also explain the steps you've given in the context of a flow that will be looking up all the files saved in one folder and copying each into it's individual named folder?

    I'm assuming the flow will need to look something like this?
     
     
     
  • Suggested answer
    Meekou Profile Picture
    200 Super User 2025 Season 1 on at
    Copy files containing unique IDs in the filenames to existing folders with the same ID in the name
    For your requirement to copy file 'Bloggs, Joe, 123456789, personal info.docx' into folder 'Bloggs, Joe (123456789)'., you will need to extract folder path and file name from 'Bloggs, Joe, 123456789, personal info.docx'.
    Try to follow steps eblow:
    • Add Compose to split the original file name by ,
    split(outputs('FileName'),',')
    • Add Compose to build the target folder name
    concat(outputs('Split_Path')[0],',',outputs('Split_Path')[1],'(',outputs('Split_Path')[2],')')
    • Add Compose to get filer name
    outputs('Split_Path')[3]
    Regards,
    Meekou
     
  • Korhanh Profile Picture
    20 on at
    Copy files containing unique IDs in the filenames to existing folders with the same ID in the name
    Hello

    To copy Word documents into specific folders for each staff member in SharePoint using Power Automate, you can follow these steps:

    1. Create a New Flow with Manual Trigger.
    2. Define Variables for Document and Folder Names.
    3. Use the split() Function to Parse the Document Name (e.g., last name, first name, staff ID).
    4. Construct the Folder Name (e.g., <last name>, <first name> (<staff ID>)).
    5. Use the "Get files (properties only)" Action to retrieve documents and loop through them to copy into the appropriate folder.

    If you have an existing workflow you developed for this, could you share it with me? This way, we can try to find a solution based on that flow.

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492