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 files between sit...
Power Automate
Unanswered

Copy files between sites while preserving path structures

(0) ShareShare
ReportReport
Posted on by

Hi!

I'm looking for some help to create a Power Automate.

Goal

Put simply, I'm trying to create an instant flow that :

1. Scans files/folders from SiteA ;

2. Looks for specific strings in file name (ie. contains "XYZ" and ".pdf") ;

3. If found, copy that file from SiteA to SiteB with same folder structure;

  1. If folder structure exists, place file in same location as SiteA (mirror);
  2. If part of, or full path is non-existent, create the part of, or full path, then copy this file at end of Path ;

This flow would be to set-up the SiteB for use. Afterwards, I would use an Automated Flow that uses the same logic, but on an Added/modified file trigger.

 

What I made so far

I'm working in a french environment in Sharepoint so I'll textually describe my flow instead of posting screenshots :

 

  1. Initialise empty variable "FullPath"
  2. Initialise empty variable "FolderPath"
  3. Get file properties in SiteA
  4. Loop all file
    1. IsFolder = true
      1. If yes
        1. Set "FullPath" Variable to dynamic Full Path
        2. Set "FolderPath" Variable to expression :

 

substring(variables('FullPath'),18, sub(length(variables('FullPath')),18))

 

(This trims down the "Shared Documents" string since dynamic Full Path starts at the Site's root)

 

  • Create Folder with "FolderPath" variable in SiteB
  • Then I use the dynamic Folder Path to copy the files satisfying the string conditions to SiteB.

What I don't like about this flow is that it takes a lot of time to complete since it scans all files AND folders, plus it creates superflous folders that won't contain any files in SiteB.

 

It seems to me that it would more optimal if the folder creation portion of the flow would be on a "per file" basis. I've searched through forums and I can't seem to find a simple way to do this, unless I'm missing something?

 

I'm not a programmer, but I learn fast. I'm not afraid of using variables and expressions to make this work if needed. I would just need a programmer's perspective/experience to help me understand how to make this work.

 

Thanks for you help!

Categories:
I have the same question (0)

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