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 / Copy new subfolder fro...
Power Automate
Unanswered

Copy new subfolder from OneDrive to Sharepoint

(0) ShareShare
ReportReport
Posted on by 13

We have a process that creates a subfolder within a designated OneDrive folder and one or more files inside that subfolder. I would like to create a flow that copies the newly-created subfolder and all of its contents to Sharepoint. As an example, our process creates /root/Submit/subfolder1/file1 and /root/Submit/subfolder1/file2. I want subfolder1, file1 and file2 copied to Sharepoint. Here's what I have so far. The "When a file is created" trigger is configured to include subfolders.

 

2021-07-26 14_35_29-Edit your flow _ Power Automate — Mozilla Firefox.png

 

This works great for subfolder1, but when subfolder2 is created subfolder1 is copied to Sharepoint again, in addition to subfolder2. All I want is the most-recently created subfolder and its contents. Is there a way to capture the parent folder of a newly-created file and only operate on that folder instead of the grandparent (in my case, "Submit")?

Categories:
I have the same question (0)
  • v-LilyW-msft Profile Picture
    on at

    Hi @esaunders 

    I set up a Flow and can achieve your needs.

    Please take a try with the screenshots as below:

    vLilyWmsft_1-1627347827407.png

    vLilyWmsft_2-1627347850599.png

    Expression:split(last(split(outputs('Get_file_metadata')?['body/Path'],'root:')),'/')

    vLilyWmsft_3-1627347890751.png

    Expression:length(outputs('Compose'))

    vLilyWmsft_4-1627347943568.png

    Expression:join(take(outputs('Compose'),add(outputs('Compose_2'),-1)),'/')

    vLilyWmsft_5-1627347984712.png

    vLilyWmsft_6-1627348030185.png

    When the new file is created in subfolder2 of OneDrive.

    vLilyWmsft_7-1627348505091.png

    It will be created in subfolder2 of Sharepoint.

    vLilyWmsft_8-1627348566635.png

    Hope the content above may help you.

    Best Regards

    If my solution helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • esaunders Profile Picture
    13 on at

    Thank you, @v-LilyW-msft! Your proposed flow works great for copying newly created files, but I also need to copy over their newly created parent folder as well. So if our process creates subfolder1/file1 in the Submit folder the flow should also create subfolder1/file1 on SharePoint. Any suggestions appreciated.

  • v-LilyW-msft Profile Picture
    on at

    Hi @esaunders 

    Have you tried to reproduce my Flow?

    According to my solution, if you create a new folder and then create a file in the new folder, both the new file and the new folder will be created in sharepoint. No need to add additional step to create a new folder.

    E.g: new folder and new file are created in OneDrive

    vLilyWmsft_2-1627453366020.png

    The new folder and new file in sharepoint are automatically created after Flow runs.

    vLilyWmsft_1-1627452876388.png

    Hope the content above may help you.

    Best Regards

    If my solution helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • esaunders Profile Picture
    13 on at

    Hi @v-LilyW-msft

     

    I did try to reproduce your flow, but I'm not seeing the behavior you describe.

     

     2021-07-28 12_59_44-Edit your flow _ Power Automate — Mozilla Firefox.png

     

    I create a new folder and file in OneDrive.

    newfolder.png

    But after running the flow, "newfolder" is not included in SharePoint.

     

    nofolder.png

  • v-LilyW-msft Profile Picture
    on at

    Hi @esaunders 

    Sorry, I didn't mark it clearly.

    Please change 'esaunders-TEST' to the Outputs of Compose 3 after'/Shared Documents/' in Folder Path.

    vLilyWmsft_3-1627543303309.png

     

    Like this:

    vLilyWmsft_1-1627542993614.png

    Hope the content above may help you.

    Best Regards

    If my solution helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • Verified answer
    esaunders Profile Picture
    13 on at

    @v-LilyW-msft

     

    No apologies necessary. I should have noticed that in your original reply.

     

    After adding that piece, there was only one thing missing. The "Submit" folder was also replicated in SharePoint, whereas I only need to capture the parent folder of the new file. I made some adjustments and now have a flow that meets my needs. I'm including it below for posterity. If you see any glaring flaws please do let me know, but otherwise I consider this issue resolved. Thanks very much for your time.

     

    Compose

    split(last(split(outputs('Get_file_metadata')?['body/Path'],'root:')),'/')

    Get New Subfolder

    last(take(outputs('Compose'),sub(length(outputs('Compose')),1)))

     

    2021-07-29 13_04_21-Edit your flow _ Power Automate — Mozilla Firefox.png

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

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard