Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Copying files from one SharePoint to another including files in sub-folders but excluding file structure

(0) ShareShare
ReportReport
Posted on by

Hi All

 

Am new to Power Automate so please excuse me if this is a basic question.

 

I have a large dataset that is currently filed in distinct and separate folders in SharePoint that I need to extract from the current SharePoint and copy to a new SharePoint site. The logic being that if the object is a file, I want to export it, but if it is a folder I want to extract all files within that folder and export them (but not the folder). End result should be a large dumping of files within the end SharePoint site.

 

I have managed to pull together the below flow from Google searches, but can't work out the logic on the left hand side - I assume I need to use some form of variable to move from each condition to the other, but am unsure how to do so.

 

Any help that can be offered will be extremely appreciated!

 

Thanks in advance

 

Screenshot 2022-12-19 211440.jpg

  • grantjenkins Profile Picture
    11,059 Super User 2025 Season 1 on at
    Re: Copying files from one SharePoint to another including files in sub-folders but excluding file structure

    If you're just copying files into a flat structure, then you can just exclude the folders in your initial Get files using the Filter Query.

     

    Important question for you: How many files/folders do you have in your source folder?

     

    For this example, I'm using the following source Folder that contains the folders and files (including nested folders).

    grantjenkins_0-1671514130804.png

     

    grantjenkins_1-1671514147209.png

     

    grantjenkins_2-1671514164847.png

     

    See full flow below. I'll go into each of the actions.

    grantjenkins_3-1671514214975.png

     

    Get files (properties only) will retrieve files and folders. In our case we only want to retrieve files, so we have the Filter Query condition below, so it only returns files (not folders). And ensure we Include Nested Items

    FSObjType eq 0

    grantjenkins_4-1671514381808.png

     

    We can then use an Apply to each to iterate over each of the files (since we know there are no folders returned - no condition required).

    grantjenkins_5-1671514452927.png

     

    My destination folder in this example would end up with the three files that were contained in the source folder.

    grantjenkins_6-1671514518347.png

     

  • v-chengfen-msft Profile Picture
    on at
    Re: Copying files from one SharePoint to another including files in sub-folders but excluding file structure

    Hi @Ablake85 ,

    Here is a test for your reference:

    [Condition] Determine whether the file is a folder
    If yes, Isfolder = true, get the full path of the folder through Get file, then get the files in it, and then copy the files in the folder to it
    If not, copy the file directly to another website

    vchengfenmsft_0-1671511841855.pngvchengfenmsft_1-1671511905666.png

     

    If this post helps, then please consider Accept it as the solution to help the other members find it.

     

    Best Regards

    Cheng Feng

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1