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 / SharePoint Copy Folder...
Power Automate
Unanswered

SharePoint Copy Folder with nested folders but exclude a specific folder?

(0) ShareShare
ReportReport
Posted on by

Hi,

 

I am using Flow to copy a folder from one Document library to another, this folder has 5 subfolders.  This is working great but I've discovered that within each of the sub folders there is another folder called "Archive" that contains data that I don't want to copy.  I would like to exclude this folder from the copy process.  

 

I was hoping to do a ODATA type filter but the "Copy Folder" control doesn't allow this.  I did think of using "Get Items", then could use a ODATA filter to exclude anything that starts with "Archive" but I couldn't work out how to translate the output from this control into copying folders.


It maybe I am trying to do something that isn't possible, but before I throw in the towel I though I'd reach out to you guys.


Thanks

Rob

Categories:
I have the same question (0)
  • Verified answer
    v-litu-msft Profile Picture
    on at

    Hi @Rob_CTL,

     

    You could use the List folder action to list all folders and files of the original root folder.

    Then use the Filter array advance mode to filter out items that it is a folder and folder name not equals to "Archive", expression as below:

    @and(not(equals(item()?['DisplayName'], 'Archive')),equals(item()?['IsFolder'], true))
    

    Then Copy folders to the destination folder.

    Hope it helps.

    Screenshot 2020-12-04 152940.jpg

     

    Screenshot 2020-12-04 153001.jpg

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Rob_CTL Profile Picture
    on at

    Hi @v-litu-msft 

    Thanks for the reply, I've implemented that is almost there, the great news is that the "Archive" folder is being excluded (note I've change "Archive" to "SS" in the formula).  I am using some dynamic content which is why it's all wrapped in a "Apply to each" control.

     

    flow-copyfolder.jpg

    The small issue I have is it doesn't copy any files that are directly in the /PlSch folder, it does however copy all folders (and contents) that is below /PlSch.  I guess the workaround would be to create a "Get Items" then just copy the files (no folders) under /PlSch, however before I go that route I just wanted to check to see if there was a neater option?

     

    Thanks

    Rob

     

  • v-litu-msft Profile Picture
    on at

    Hi @Rob_CTL,

     

    You could use Copy files action instead of Copy folders.

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Rob_CTL Profile Picture
    on at

    Hi @v-litu-msft 

     

    Hopefully you can help me again, I've been playing with the flow and I've discovered the filtering in the above examples is restricted to a single folder level so it's not finding the other "SS" folders below the other nested folders.  To help visualise the folder structure is like this:

     

    flow-argh3.jpg

     

    I had the thought of using "Get Files (Properties Only)" control then apply a filter array control that result like this:

     

    flow-argh1.jpg

    From the output I can see that it has excluded any files or folders that contain "SS" which is great.  Now I've hit the issue where I can't use the filter array in any of the copy controls, it doesn't appear as a dynamic option.

     

    flow-argh2.jpg

    Frustratingly I've got the data in a format I want but I can't get it out 🤔

     

    Any insights would be gratefully received.

     

    Thanks

     

     

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 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard