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 / Sharepoint file move f...
Power Automate
Unanswered

Sharepoint file move from one folder to another folder based upon name

(1) ShareShare
ReportReport
Posted on by 26

I am trying to build flows to move files for employees based upon name in the files. We place all files for the week in a folder named All Employees, and then I need the flow to move the files to individual folders based upon a portion of the file name. For example, it would begin like this:

 

Folder - All Employees

---File Name - Josiah Bartlett

---File Name - Sam Seaborn

---File Name - Leo McGarry

---File Name - Josh Lyman

 

I am looking to have the files moved automatically to folders in the same Document library:

Folder - House, Subfolder - Josiah Bartlett

Folder - Policy, Subfolder - Sam Seaborn

Folder - House, Subfolder - Leo McGarry

Folder - Policy, Subfolder - Josh Lyman

 

I am looking for the flow to look at the file names in the All Employees, and automatically move to same named subfolders. Is there a method to do this? Thanks!

Categories:
I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @coyandrew 

     

    How folder name to be moved is determined ? as  file name Josiah Bartlett is moved to subfolder named Josiah Bartlett which is under folder House - how the House folder is determined from the file ?

     

    Could you elaborate it better ?

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • coyandrew Profile Picture
    26 on at

    I am trying to have it iterate through the folders and subfolders looking for a match.

  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @coyandrew 

     

    Try this approach - This could help

     

    For demo purposes I have created the folder structure like below as per your example directly under document library

    Nived_Nambiar_0-1720462601301.png

     

    Inside House and Policy , you can expect subfolders 

    Under all employees, these are files 

    Nived_Nambiar_1-1720462714541.png

     

    Flow design 

     

    I am assuming flow design to be manually trigger, based on your requirement change it accordingly.

     

    1. Use get files (properties only) action to get all files details inside the All employees folder

    Nived_Nambiar_2-1720462808281.png

     

    2. Loop through each file details using apply to each loop

    Nived_Nambiar_3-1720462851132.png

     

    Inside the loop- try the following steps 

    2.1- use get files (properties only) action to get folder details which has the name of file within document library as shown below

    Nived_Nambiar_5-1720463065896.png

     

     

    Expression used in odata filter query

    split(items('Apply_to_each')?['{FilenameWithExtension}'],'.')?[0]
     
    The above OData filter query helps to query folder with name of file without extension. Also ensure to set include nested items as Yes so it searches for subfolder level as well.
     
    2.2 - next use move file to move the file to the folder path.
    Nived_Nambiar_6-1720463140639.png

     

    Nived_Nambiar_8-1720463207250.png

     

    Expression used- 

    first(outputs('Get_files_(properties_only)_2')?['body/value'])?['{FullPath}']
     
    Also set the concurrency of apply to each loop to make runs parallel so to run faster.
    Nived_Nambiar_9-1720463263091.png

     

    Once run is completed- you can see that it is moved to respective folder like below

    Nived_Nambiar_10-1720463326509.png

     

    Hope it helps !

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

     

  • coyandrew Profile Picture
    26 on at

    I believe I have most set up properly but am getting a failure on the second Get Files:

     

    coyandrew_0-1720525950659.png

    Step 1:

    coyandrew_1-1720525986826.png

     

    Step 2:

    coyandrew_2-1720526039686.png

    Step 3:

    On my apply to each, I only have body/value available, not value:

     

    coyandrew_3-1720526113793.png

     

    coyandrew_4-1720526137131.png

     

    coyandrew_5-1720526164235.png

    coyandrew_6-1720526195761.png

    If you can spot my issue, this would be amazing and fix so many issues for us!

     

     

     

  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @coyandrew 

     

    How you need to trigger the flow then ? is it via when file is added to folder ?

    Also body/value dynamic content is same as value dynamic content.

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • coyandrew Profile Picture
    26 on at

    I am triggering on File is Created.  Here are the results I am receiving:

     

    coyandrew_0-1720547554572.pngcoyandrew_1-1720547577129.png

     

     

     

  • coyandrew Profile Picture
    26 on at

    Here are some more screen shots showing the testing:

     

    coyandrew_0-1720549219633.png

    The items inside the loop do not seem to execute and skip the files I have in the ALL EMLPOYEES folder.

     

    coyandrew_1-1720549282128.png

     

    The setup inside the flow:

     

    coyandrew_2-1720549354101.pngcoyandrew_3-1720549380442.png

     

  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @coyandrew 

     

    From screenshot, i did not get why you are not able to iterate through the loop as it has files there. Did you added any filter condition in get files action used after trigger ?

     

    Also if you want to trigger when file is added- and then move that file only- then use this approach (would be simple)

    Nived_Nambiar_0-1720577541660.png

     

    Expression used- 

    split(triggerOutputs()?['body/{FilenameWithExtension}'],'.')?[0]
     
    Now iterate through the results and move the file to required folder
    Nived_Nambiar_1-1720577610173.png

     

    Nived_Nambiar_2-1720577696696.png

     

    Nived_Nambiar_3-1720577728495.png

     

    Hope it helps !

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • coyandrew Profile Picture
    26 on at

    Good Morning, I am still having issues with the new solution you provided. While the flow says it is successful, the files never move.

     

    coyandrew_0-1720612091900.png

     

    coyandrew_1-1720612091820.png

     

     

    I tried two methods, one with the files in the same site address and received an error they could not be moved within the same site, and then tried a different site for current versus destination. The second try says success but the files never move. Would you be able to assist?

  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @coyandrew 

    well i have tried moving within same site, it was successfull. Could you confirm whether you have mapped dynamic contents correctly - like for identifier as shown below?

    Nived_Nambiar_0-1720628384494.png

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

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

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard