How to check whether an attachment is a PDF in Power Automate
Updated 2 November 2026
The expression:
endsWith(toLower(items('For_each_attachment')?['name']), '.pdf')Checks the file name ends in .pdf, ignoring upper or lower case.
Where it goes
A Condition inside a loop called For each attachment.
- In the Power Automate designer, click in the box that needs the value.
- Select the fx (Expression) button that appears next to the dynamic content list.
- Paste the expression and select Add. It should appear as a purple fx chip; if you can see it written out as text, it went in as plain text and won't run.
Example output
true (illustrative; AutomateAlong doesn't run expressions)
The common mistake
contains(items('For_each_attachment')?['name'], 'pdf')Matches 'pdf-guide.docx' too, and misses '.PDF'. Check the end of the lower-cased name.
Before you rely on it
- Your loop is renamed For each attachment. Change the name to match yours.
Change it for your flow
Step names inside an expression must match your steps exactly, with underscores for spaces: Get_items, not Get items. To adapt it, open it in the Expressions checker, which points at any bracket, quote or name that's wrong and suggests the corrected version. To write a different one from plain English, describe what you need on the same page.
Related
- How to compare text ignoring capitals in Power Automate
- How to check if a value is blank in Power Automate (empty)
- How to check that text is a whole number before using int() in Power Automate
- How to use a SharePoint Yes/No column in a Condition in Power Automate
AutomateAlong is independent and isn't affiliated with Microsoft. Microsoft and Power Automate are trademarks of the Microsoft group of companies.