Do you need to filter only some of the documents in a library using Power Automate? E.g. just Word documents to convert them to PDF?
To use Power Automate to filter a specific documents we need to understand document properties first. Every document uploaded into SharePoint has an internal property FileLeafRef
, which is basically the Name of the document including extension, e.g. myDocument.docx
. Knowing this, you can use Filter Query in the Get files (properties only) (SharePoint) in the following format:
substringof('.docx', FileLeafRef)
This query will tell the action to return only files where ‘.docx’ string is part of the file name (incl. extension). That means, only Word documents will be filtered.
You can replace the .docx with any other file extension you need. And you can even sort the returned files if needed.
Hello Tom,
I have used get files( properties only) filter query to get attachments but I can only retrieve one attachment, eg- FileLeafRef eq ‘items(‘Apply_to_each’)?[‘Uniquenumber’]}_1.TXT’ or items(‘Apply_to_each’)?[‘Uniquenumber’]}_1.PDF’
I want to be able to get all attachments with the unique number whether it is in .txt, .pdf, .doc. When I run the filter query individually for these, it works fine but I am not able to get all the attachments with the unique number (having different document format) to be emailed in the next step. Please help
Hello Anita,
use the substringof(…) filter as explained in the article instead of the eq.