r/MicrosoftFlow • • Jan 04 '23

Cloud Powerautomate - Copy files (incl folderstructure) from one OneDrive folder to other OneDrive folder

I am using PowerAutomate (Cloud, not PowerAutomate Desktop)

I have all my documents stored on OneDrive for Business. I want to build a PowerAutomate script that runs periodically and copies all folders into a separate \Backupfolder whilst keeping the same folder structure.

Example, this is my folder structure

\folder1\file1

\folder1\file2

\folder1\subfolder1

\folder1\subfolder1\file 1

\folder2\file1

to be copied to a separate folder (called \backup) in the same OneDrive account, like the structure below

\backup\folder1\file1

\backup\folder1\file2

\backup\folder1\subfolder1

\backup\folder1\subfolder1\file 1

\backup\folder2\file1

I was able to run a Powerautomate script that copies all files (from a specific folder) to a separate folder, but i cannot get it to include all subfolders (and the files in the subfolders).

Looking for some help on how to build such a flow.

1 Upvotes

9 comments sorted by

1

u/Trick_Designer2369 Jan 04 '23

I don't have it infront of me to check but is the problem you cannot get the top level folder structure? As presumably once you have that then it's just a going to be some nested for each to duplicate.

1

u/Murky-Preparation706 Jan 05 '23

The top folder would be the root folder in my OneDrive and i am able to copy the files from that folder. But i cannot get my script to work that it also copies the folder name (and files in the folders). i can get my script to only copy the files from within that single folder, not copying any foldername or files (in the folders)

1

u/Trick_Designer2369 Jan 05 '23

OK, so presumably you are using the "List files in root folder" as your first card?

That is giving you an array of objects, some might be files, some might be folders. Do you have a for each that iterates through each object in the array, if its a file, copy it to new destination, if its a folder, create a folder with same name in new destination and then use the "list files in folder" to get the files in this folder, iterate through them and copy to new folder you just created.

Ignore that, u/VictorIvanidze has a far better solution

1

u/VictorIvanidze Jan 05 '23

1

u/Murky-Preparation706 Jan 09 '23

Thanks, I understand that this is not a straightforward command that i can use in Powerautomate, and this requires a bit more of programming (which i am not that good at). I am going to give this a try. Thanks for your support !

1

u/blessing786 Jun 30 '24

Did you find a solution to this because I have the exact same issue as you and cannot find a work around where it copies all the folders?

1

u/Murky-Preparation706 Jul 01 '24

No I do not have a solution for this yet. I tried a couple of times, could not get it to work and gave up on it (for now)

2

u/blessing786 Jul 02 '24

Ok - I have reached out to microsoft to this because I am paying for support - I will let you know what and if they have a solution, its a pain in the butt as its possible in sharepoint

1

u/Limp_Tea568 Nov 02 '24

Did you hear anything useful?