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 / How to copy and paste ...
Power Automate
Answered

How to copy and paste folders and subfolders only from one site to another

(1) ShareShare
ReportReport
Posted on by 10
Good day, everyone!
 
I think my idea is simple, but I could not find a solution in the internet yet.
 
I need to copy a Folder and all its subfolders from one site to another, but not copying the files in them, only the folders.
 
Example ---

Source:
Folder 1: a bunch of files + FolderZ (with a bunch of files) + FolderY (with a bunch of files)
 
Destination:
Folder1: No files + FolderZ (no files) + FolderY (no files)
 
Any ideas?
Categories:
I have the same question (0)
  • Suggested answer
    trice602 Profile Picture
    15,404 Super User 2025 Season 2 on at
    Hi,
     
    I think you can start with something like this.  Here I am listing all files/folders in a root folder, then using filter query to check if isFolder = true, that's going to give me all the subfolders I want.  From there, you can continue and create folders in your new site.
     
     

    ------------------------------------------------

     

     

    ⭐ If this was helpful, please like and check the box below "Does this answer your question" to help others find this too!

     

     

    Always glad to help! 💯💯💯💯💯

     

    Tom

     

    Follow me on LinkedIn - Thomas Rice, PMP | LinkedIn

  • Verified answer
    DJ_Jamba Profile Picture
    2,837 Super User 2025 Season 2 on at
    I managed to do this in 4 actions (plus a manual trigger):
     
     
     
    1. Get files (properties only):
     
     
    Filter Query: FSObjType eq 1
     
     
    2. Select:
     


    You don't really need to map FolderName, but I wanted to add it to check the folders were all there before I added the next action.
    I'm doing a replace in FolderPath because the library I'm copying from (Shared Documents) is also the library I'm copying to in the other SharePoint site
     
    Map (copy and paste):
     
    {
      "FolderName": @{item()?['{Name}']},
      "FolderPath": @{replace(item()?['{FullPath}'],'Shared Documents/','')}
    }
     
    3. Apply to each (Loop over folder structure)
     
     
    Site address: The other SharePoint site
    List or Library: The library in the other SharePoint site
     
    Folder Path: 
    @{items('Loop_over_folder_structure')?['FolderPath']}
     
    If the folder already exists in the target library, it will not fail (it will not bother trying to create the folder) 
     
  • oficialricardoc Profile Picture
    10 on at
    Hey @DJ_Jamba, that was very helpful. Is there a way to include all subfolders and subfolders and subfolders? Just set Nested Items to True?
    We have many that needs to be replicated to this new site...
  • DJ_Jamba Profile Picture
    2,837 Super User 2025 Season 2 on at

    The API (Get files (properties only)) already does that by traversing down all subfolder levels using FSObjType eq 1
    The solution I provided will create the same folder structure including all nested subfolders in the other SharePoint library

    Note: If you have more than 500 subfolders, increase the top count to e.g. 2000

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

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard