cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
esaunders
New Member

Copy new subfolder from OneDrive to Sharepoint

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")?

1 ACCEPTED SOLUTION

Accepted Solutions

@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

View solution in original post

6 REPLIES 6
v-LilyW-msft
Microsoft
Microsoft

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.

 

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.

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.

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

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.

 

@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

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (1,458)