check if file exist on Sharepoint Online by File Name with Power Automate

I am trying to create a flow in Power Automate Cloud that allows me to extract some files from Google Drive and copy them to a Sharepoint folder. But before copying it, it has to check by the file name, that the file does not already exist in the sharepoint folder. I have managed to do the whole flow, except the checking. I would be very grateful for your help. Thank you very much. Best regards.

Upvotes: 0

Views: 12520

Answers (1)

Skin
Skin

Reputation: 11197

A File exists action doesn't currently exist but you can use the Get file metadata using path action from the SharePoint connector to do the same sort of thing.

This flow below shows you an example of what you can do ...

Flow

For demonstration purposes, I've created an array with a list of file names (full path required) that I will then test the existence for.

One of those files doesn't exist.

File Names Array

Files

I then loop through each one of those and try and get the metadata for each file.

If the resulting statusCode from the call to get the metadata is not equal to 200, then we know the file doesn't exist.

Condition

Examples ...

Item 2

Item 3

To make this work however, you need to make sure that the Condition step will execute after the metadata call no matter what the result.

Do this by making sure the Configure run after settings are correct ...

Settings

Run After

So after all of that, all you need to do is deal with the true and false sections of the condition.

Upvotes: 0

Related Questions