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 / Get All File but to ex...
Power Automate
Suggested Answer

Get All File but to exclude the ones inside a specific folder using Odata filter

(0) ShareShare
ReportReport
Posted on by 30
I have this action to get all files modified before specific period:-
 
 
 
now i wan to exclude all the files inside this folder and its subfolders  "/shared documents/Invoices/Annual Recurring".
 
 
how i can do so using server-side code? I know I can get all files and then add a condition to check the file Path, but i want to do the filter from the beginning.
 
Thanks
Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,874 Most Valuable Professional on at
     
    You can add another filter on the FileDirRef field (aka {Path}). 

    Below is an example
    Small heads-up, the number of files might effect the outcome as well. How many files are you storing in this library?
     
    (FSObjType eq 0) and (Modified lt '@{addDays(utcNow(), -1)}') and (FileDirRef ne '/sites/SiteName/Shared Documents/Invoices/Annual Recurring')



     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, LinkedIn, Bluesky profile or Youtube Channel
  • CU31101829-0 Profile Picture
    30 on at
    @Expiscornovus thanks for the reply, i have total of 110K files/folders.. but i am getting those files to be moved to archived site, so it is fine if i do them in batches..
  • CU31101829-0 Profile Picture
    30 on at
    @Expiscornovus also should it be ne or does not start with?
  • CU31101829-0 Profile Picture
    30 on at
    @Expiscornovus i tried this:-
     
    FSObjType eq 0 and Modified lt '2025-11-03T12:53:04.0470999Z' and not(startswith(FileDirRef ,'shared documents/invoices'))
     
     
    but i got invalid expression 
  • Michael E. Gernaey Profile Picture
    53,978 Moderator on at
     
    Since you want it to also include subfolders of that folder I do not believe NE is enough.
     
    I believe you are going to have to have a condition in your flow that will check if it startswith and then that path and if so ignore it, as deeper down it will not have that path it will be different in that subfolder... I have to test it to be sure but I am not 100% positive that that filter will stop it from going into subfolders of that folder, it will simply ignore parent level files..
     
    hmmm @Expiscornovus I am curious lol now I have to check but maybe you know off the top of your head
  • CU31101829-0 Profile Picture
    30 on at
    @Michael E. Gernaey i tried this with ne
     
    but even the exact folder will still be retrieved:-
     
  • Expiscornovus Profile Picture
    33,874 Most Valuable Professional on at
     
    Afaik the FileDirRef also returns the /sites/SiteName bit. So, you would need to include as well in your check.
     
    @Michael E. Gernaey, regarding the subfolders, you are right. Ne is not sufficient 👍Totally forgot about that part, my bad.  😂
     
    I think OData with SharePoint REST API still doesn't like the negative string functions. So, probably you would have to filter them out with a Filter Array afterwards. For reference see this GitHub issue: https://github.com/SharePoint/sp-dev-docs/issues/9823


     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, LinkedIn, Bluesky profile or Youtube Channel
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,978 Moderator on at
     
    Yes, I am not sure the confusion. I said NE would NOT work so you are posting that you used NE and it did not work.
     
    Yes, I said it would NOT work, I was specific in saying you need a condition which has nothing to do with the Filter NE.
     
    You can try to built out a complete Filter Array, but its easier to have a configurable list of paths you do not want. If its less than 10 then make it a condition or use an advanced filter with a configurable list you get from an Environment Variable or from SharePoint or file.

    If these suggestions help resolve your issue, Please consider Marking the answer as such and also maybe a like.

    Thank you!
    Sincerely, Michael Gernaey

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 959

#2
Valantis Profile Picture

Valantis 872

#3
Haque Profile Picture

Haque 589

Last 30 days Overall leaderboard