web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How do I Filter Out It...
Power Automate
Unanswered

How do I Filter Out Items from Get subfolders in Folder menus in Power Automate Desktop

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

I am new to Power Automate Desktop, and I am trying to create automation to make a temporary backup of a user's files prior to IT replacing their PC with a newer model. I got my flow to copy the Folders for Desktop, Downloads, & Favorites for each user of another PC on the domain and copy them to IS network storage drive. However, I can't get it to copy the My Documents folder. I keep get an error that "Access is denied for subfolder "My Music", "My Videos", and "My Pictures" which seem to be hidden within the My Documents folder. I have admin rights and I have tried running Power Automate with elevated permissions but still no luck. So, the easiest fix I can think of is to filter out the subfolders I don't want. What is the syntax to filter out an item using the Folder filter options in the Get Subfolders in Folder action menu? 

 

Alternatively, if anyone knows a workaround to the "Access denied to subfolder" error I am getting when trying to copy the My Documents folder I would love to know the fix.

Thanks

  • momlo Profile Picture
    1,527 Super User 2024 Season 1 on at

    Not direct solution to "access denied" on those special folder (I tested myself and got the same), but another approach you could take is to use DIR dos command to get root folders in Documents - that will give you list of visible folders, then copy these in loop.

     

    Copy and paste the code into your PAD:

     

    Folder.GetSpecialFolder SpecialFolder: Folder.SpecialFolder.Personal SpecialFolderPath=> DocumentsFolder
    Scripting.RunDOSCommand.RunDOSCommand DOSCommandOrApplication: $'''DIR /D /B %DocumentsFolder.FullName%''' StandardOutput=> RootFolders StandardError=> CommandErrorOutput ExitCode=> CommandExitCode
    Text.SplitText.Split Text: RootFolders StandardDelimiter: Text.StandardDelimiter.NewLine DelimiterTimes: 1 Result=> RootFolders
    Variables.RemoveItemFromList.RemoveItemFromListByValue Item: $'''%''%''' ItemMatchAllOccurrences: True List: RootFolders
    LOOP FOREACH CurrentItem IN RootFolders
     Folder.Copy Folder: $'''%DocumentsFolder%\\%CurrentItem%''' Destination: $'''%DocumentsFolder%\\backup''' IfFolderExists: Folder.IfExists.Overwrite CopiedFolder=> CopiedFolder
    END

     

    However, i recommend you take a look at another dos command: xcopy, perhaps this will help you to achiove your goal easier than automating everything with PAD:

     

    https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for the info! I will definitely have to read up on it. I can read and/or get the jist of scripts, but my grammar/syntax isn't great. This was mostly a thought experiment to try out the program. For some context, I work for small IT company that contacts within a hospital and we have several scripted tools, but the team member that wrote them has since left and I was looking for a way to centralize tools while limiting the amount scripting knowledge required to keep them updated. I wanted to try using Power Desktop Automate since it has If/Else logic and AD integration.

    I was able to work through the issue by using "Get List of Subfolder" to report all folders and the used "for each" logic to check the "CurrentItem" name and remove the entries from the folder list if it contains My Music, Pictures, or Videos. Still seems a little strange that you can't even touch those folders and I can't for the life of me find clear directions for how to use the Filter options.

  • momlo Profile Picture
    1,527 Super User 2024 Season 1 on at

    Filter works as in windows explorer, this is not full regex hence i doubt you can exclude the specific folders using it 😞

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Well, that's a bummer, but good to know. It would have been amazing if I could filter out items in a list that way. Would make my flows much cleaner. Thanks for the help!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 243 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 211 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 190

Last 30 days Overall leaderboard