Your flow is about to save a report to SharePoint, but a file with that name may already be sitting in the library. Power Automate has no single “file exists” action, so you need a small test before the flow creates, replaces or deletes anything.
In this tutorial, we’ll show you how to do a power automate check if file exists in SharePoint test three ways, using one demo flow we built and ran on 11/01/2026. We’ll also check a specific folder and cover what to do next: create the file, overwrite it, or delete it only when it exists.
Quick answer: Add Get files (properties only) with the Filter Query FileLeafRef eq 'your file name', then a Condition that tests length(outputs('Get_files_(properties_only)')?['body/value']) is greater than 0. True means the file exists. To check one exact folder path, use Get file metadata using path and treat a failed action (Run after: Has failed) as “missing”.
What You Need Before You Start
- A Power Automate license that includes the standard SharePoint connector (Microsoft 365 plans do).
- Contribute access to the document library. Ours is SPGDemo Project Files on the /sites/SPGuides site.
- A few test files. We used Project Charter 2026.txt and Budget-Q4-2026.txt in the root, Website-Redesign-Proposal.txt in a Proposals folder, and Intranet-Proposal.txt in Proposals/2026.
We’ll test three names against this library: one in the root, one inside Proposals, and Annual-Report-2026.txt, which doesn’t exist. If you’re new to cloud flows, our Power Automate tutorials hub covers the basics first.
Step 1: Create an Instant Flow with a File Name Input
- In Power Automate, select Create > Instant cloud flow.
- Name it SPGuides Demo – Check if file exists, pick Manually trigger a flow, and select Create.
- Open the trigger, select Add an input > Text, and name it File name.

In a real flow, the name usually comes from an email attachment or a form. A manual input just makes testing quick, the same way we tested when we created a file in Power Automate.

Step 2: Check the Library with Get Files (Properties Only)
We reach for this method first because it never fails the run: an empty result simply means no match.
- Add Get files (properties only) from the SharePoint connector.
- Set Site Address to your site and Library Name to SPGDemo Project Files.
- Open Advanced parameters, add Filter Query, and type the filter below. FileLeafRef is the internal name of the file name column (see our OData filter query examples).
FileLeafRef eq '@{triggerBody()?['text']}'

Next, add a Condition. In the left box, enter this expression, choose is greater than, and type 0 on the right:
length(outputs('Get_files_(properties_only)')?['body/value'])

The length() function counts the rows the filter returned, so we don’t need an Apply to each loop. Our Power Automate IF length guide shows more ways to use it. In the True branch, add a Compose with this text so you can see where the file lives:
Found @{triggerBody()?['text']} at @{first(outputs('Get_files_(properties_only)')?['body/value'])?['{FullPath}']}
We ran it with Budget-Q4-2026.txt. The Condition went True and the Compose returned “Found Budget-Q4-2026.txt at SPGDemo Project Files/Budget-Q4-2026.txt”. For Annual-Report-2026.txt, the action returned 0 rows and the flow took the False branch.


Step 3: Check if a File Exists in a Specific SharePoint Folder
Here’s what surprised people on our team: Get files (properties only) searches subfolders too. We tested Website-Redesign-Proposal.txt, which lives only in Proposals, and the filter still found it at SPGDemo Project Files/Proposals/Website-Redesign-Proposal.txt.

That also means the same name in two folders returns two rows.
To stay inside one folder, Microsoft documents two parameters on the same action: Limit Entries to Folder (pick a folder, or leave it blank for the whole library) and Include Nested Items (subfolders are included by default). If you need the folder path as text, here’s how to get a document library folder path.
When you already know the full path, Get file metadata using path is the simpler check:
- Add Get file metadata using path and pick the same site.
- In File Path, type the library, the folder and the file name token, as shown below.
- Add a Compose named File exists after it. In its Settings, keep Run after on Is successful.
- Add a second Compose named File missing, open Settings > Run after, select the metadata action, and check only Has failed.
/SPGDemo Project Files/Proposals/@{triggerBody()?['text']}

With Website-Redesign-Proposal.txt, the metadata action succeeded. With Annual-Report-2026.txt, it failed with “File not found” (NotFound) and the File missing Compose ran instead. For bigger flows, wrap this in a scope, as in our try catch pattern for Power Automate.

Note: a handled failure still marks the run as Failed in run history. Our three test runs show Succeeded, Failed, Failed, even though every missing-file case went down the planned path.

Step 4: Use the SharePoint REST Exists Property
If you’re comfortable with REST, add Send an HTTP request to SharePoint. Set Method to GET and use this Uri (the path is server-relative, so it starts with /sites/SPGuides):
_api/web/GetFileByServerRelativeUrl('/sites/SPGuides/SPGDemo Project Files/@{triggerBody()?['text']}')/Exists
For Budget-Q4-2026.txt in the root, the body came back like this:
{
"value": true
}

The catch is the missing case. SharePoint doesn’t return false; it returns HTTP 404 with “The file … does not exist” (Microsoft.SharePoint.SPException), so the action fails. We got exactly that for the Proposals file on the root path.
Treat “Has failed” as missing, just like Step 3. GetFileByServerRelativePath(decodedurl=’…’) behaved the same in our browser test. We use the same action to delete files with the REST API.
Which Method Should You Use? (Cheat Sheet)
| Method | Best for | When the file is missing | Subfolders |
|---|---|---|---|
| Get files (properties only) + length() | Name-only checks anywhere in a library | 0 rows, False branch, run succeeds | Searched by default |
| Get file metadata using path + Run after | One exact folder path | Action fails (NotFound), Has failed path runs | Only the folder you type |
| Send an HTTP request to SharePoint, /Exists | REST users, server-relative URLs | HTTP 404, never false | Only the path you type |
We’d pick Get files for most flows, because the run history stays green.
What to Do Next: Create, Overwrite or Delete the File
Once the Condition knows the answer, the follow-up actions come straight from the SharePoint connector reference on Microsoft Learn:
- Create only if it doesn’t exist: put Create file in the False branch. It needs Site Address, Folder Path (must start with an existing library), File Name and File Content. It has no overwrite option, which is why we check first.
- Overwrite if it exists: in the True branch, use Update file. It takes a File Identifier and new File Content and updates that file’s contents. The identifier is on the row from Get files.
- Delete if it exists: add Delete file with the File Identifier, then create the new file. With REST, the documented delete is a POST with X-HTTP-Method DELETE, shown below. To clear a whole folder, see how to delete all files in a SharePoint folder.
- Copying instead: Copy file has an Overwrite Flag that decides whether an existing destination file is replaced.
Because Get files returns an array, pick the identifier with first(), for example first(outputs('Get_files_(properties_only)')?['body/value'])?['{Identifier}']. Here’s the REST delete for the same file:
Method: POST
Uri: _api/web/GetFileByServerRelativeUrl('/sites/SPGuides/SPGDemo Project Files/@{triggerBody()?['text']}')
Headers:
{
"X-HTTP-Method": "DELETE",
"IF-MATCH": "*"
}
Common Mistakes to Avoid
- Comparing Name to Name in an Apply to each: without a Filter Query, Get files returns every file, and a loop like that matches far more than you expect. Filter on FileLeafRef and test length().
- Expecting false from REST: /Exists returns 404 for a missing file, so the action fails. Add a Has failed path.
- Forgetting subfolders: the same name in two folders gives 2 rows. Check {FullPath} or use the path method.
- Wrong path format: the metadata path starts with the library (/SPGDemo Project Files/…), while REST needs the server-relative URL (/sites/SPGuides/…).
- Reading a red run as a bug: a handled NotFound still shows Failed in run history.
If file names come from users, it also helps to check if the filename contains a value before you save anything.
Can You Check if a Folder Exists in SharePoint the Same Way?
Yes, the pattern carries over. The connector has a Get folder metadata using path action that takes a Folder Path, so put the same Is successful and Has failed pair of Compose actions behind it. If you script SharePoint instead, we show how to check if a folder exists with PnP PowerShell.
Next Steps
Swap the manual trigger for the event you actually use, keep the Get files check, and add the follow-up action you need. Then add a Power Automate condition with multiple rules if you also want to test file size or modified date.
We use these related file and list checks in the same kind of flows:
Frequently Asked Questions
How do I check if a file exists in a SharePoint folder in Power Automate?
Use Get file metadata using path with the full folder path and a Compose that runs after it Has failed. Or set Limit Entries to Folder on Get files (properties only).
Why does my file exists check fail the flow run?
The path and REST methods fail on a missing file, and the run shows Failed even when Run after handles it. Get files (properties only) returns 0 rows instead, so the run succeeds.
How do I delete a file only if it exists?
Put Delete file in the True branch of the length() Condition and pass the Identifier from the Get files result.
How do I overwrite a file if it already exists?
Use Update file with the existing Identifier in the True branch and Create file in the False branch.
Where are the SharePoint actions documented?
Microsoft lists every parameter of Get files (properties only), Get file metadata using path, Create file, Update file and Delete file in the SharePoint connector reference.

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.