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 check if a file...
Power Automate
Unanswered

How to check if a file exists in a SharePoint library by file name?

(0) ShareShare
ReportReport
Posted on by

I am trying to get a true/false response on if a file exists in a SP library given the file Name. The files do not have Titles. Based on my research, I have seen suggestions to use the Get file content using path action. I am able to test that and I do get that to run successfully. However, I don't know where to go from here. I'd like to have a condition after to essentially check if the file was found. What would it be checking on?

Edit: Now thinking Get file content using path is not the best action because the Flow fails on a bad path which I don't want to happen

Categories:
I have the same question (0)
  • Verified answer
    RezaDorrani Profile Picture
    12,143 on at

    Hi @Anonymous 

     

    Use get files properties only

    do query on file name and then check the length using expression 

     

    Untitled.png

     

    Regards,

    Reza Dorrani

     

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

  • v-alzhan-msft Profile Picture
    on at

    Hi @Anonymous ,

     

    Have you take a try with @RezaDorrani 's workaround, you could take a try to achieve your needs.

     

    Have your problem be solved?  If yes, please go ahead and mark the post as solved by clicking “Accept as Solution” so that this thread will be marked for other users to easily identify!

     

    Best regards,

    Alice       

     

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

  • srose Profile Picture
    94 on at

    But what do you do once you check the condition? How does that translate back to powerapps to complete the check?

  • BranislavK Profile Picture
    6 on at

    Hi @RezaDorrani 

     

    I have been trying to duplicate the solution you described. I got error:

    The expression "FileLeafRef eq INS-TEST----.pdf" is not valid. Creating query failed.
    clientRequestId: 35c0a1f9-d680-46e2-bdd2----
    serviceRequestId: 35c0a1f9-d680-46e2-bdd2---

     

    Can you please advise what might be the issue?

     

    Thank you in advance.

  • BranislavK Profile Picture
    6 on at

    Hi @RezaDorrani 

    I see the issue I had not using single quotes for the file reference, after it was fixed, it has been working well. Sorry for the unnecessary question not noticing the typo issue at first.

    Thank you.

  • rgentile Profile Picture
    89 on at

    Thanks Reza, your solution helped me solve a problem.

  • AndresBMR96 Profile Picture
    3 on at

    This solution is superb! One thing you could do if you want to compare various files rather than just one file change

    FileLeafReq eq 'contratc.docx' 

    to:

    FileLeafReq eq '[FILE NAME]' 

    Where [FILE NAME] is a string variable of the "display name" of the file )which you can get from a "get. attachments" function.

  • rsadhula Profile Picture
    4 on at

    Hi @RezaDorrani ,

    FileLeafReq eq 'contratc.docx' 

    Above filter doesn't work if we have more than 5000 items in library, Do we have any alternative for this ?

     

  • ques0buffet Profile Picture
    105 on at

    I'm using the odata filtering on a library with 20k+ items without issue.

     

    FileLeafRef eq 'filename.pdf' 

     


    Note the  FileLeafRef   name.

  • NPrice99 Profile Picture
    1,302 on at

    Hi @RezaDorrani

     

    I used this one - the file existed but the response from length(body('Get_files_(properties_only)')?['value']) was zero.  THis one I think is a better way - How to check if SharePoint item already exists in Power Automate (tomriha.com)

     

    Regards

     

    Nigel

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

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard