Check if a file or folder exists power automate desktop
A lot of times we use files and folders while designing business process automation.
Sometimes we need to perform the operations based on if the file or folder exists at a certain place in the project folder.
In this article we will see how we can achieve this task.
Let’s jump into the practical implementation of this task:
Checking for File:
Step1: Drag and Drop if file exists action from actions panel to flow designer panel as shown below:
Let’s see the required parameters for this action:
- If file – Here we need to select the state of the file. In this section, we have two different states which are discussed below:
- File path – Provide the file path of the file that you want to check.
The two different states that you can select are mentioned below:
- Exists
- Doesn’t exist
Firstly, let’s see the exists state which is shown below:
Here:
The state is exists and provided with the file path for the action to check.
Now let’s see the Doesn’t exist state which is show below:
Here:
The state is doesn’t exist and provided with the file path for the action to check.
This is how it appears in the power automate desktop flow designer:
The main functionality is that if the file exists it enters into the actions that are placed in between if and end.
If the file doesn’t exists then it won’t enter inside the if action.
This is how we can check if the file exists or not in power automate desktop.
Checking for folder:
Step1: Drag and Drop if older exists action from actions panel to flow designer panel as shown below:
In this action, the states remain the same as the file exists action but instead of file path you have to folder path.
If you want to check the functionality then refer to the file that exists action functionality that is mentioned above.
Is there a way to check if file exists using a wildcard? For instance I have a file that is sometimes placed as .txt other times placed as .csv. So in my If file exists I would need TestFile*
This works if other areas such as copy/move file etc. But I can not seem to get it to work in If file exists.
Thank you in advance.
Hi Dustin,
If you want to check for both extensions then try like this condition1(file.txt) or condition2(file.csv).