How to check the particular folder exists in sharepoint by using Microsoft 365 scope

Hi All,

How to check the particular folder exists or not in the sharepoint, I am using the microsoft 365 scope activity. Can someone guide me please.

Hi @TJamuna

  1. Microsoft 365 Scope: Provide your Client ID, Tenant ID, and Client Secret for authentication.

  2. Find Files and Folders: Set the Site URL to https://<tenant>.sharepoint.com/sites/<site_name>, specify the Folder Path (e.g., Shared Documents), and optionally use the Query to search for a folder by name (e.g., name eq 'TargetFolder'). The result will be stored in the FilesAndFolders output.

  3. If Activity: Check if the FilesAndFolders.Count is greater than 0; if true, display a message saying “Folder exists”, otherwise show “Folder does not exist”.

Or try below link:

Hi @TJamuna,

You can do below:

  1. Under O365 scope, use find files and folders activity
  2. set up its filter/query box as the folder you wish to find.
  3. Set up other properties for this activity like url, drive name etc.
  4. Set the output → first property to a variable. and then check IsNothing(firstitemvariable), it will return true if folder doesn’t exists.
  5. Alternatively, assign variable to output → results property and you can check resultsvariable.count>0 or not

Also, linking activity documentation:

hope this helps.

Regards
Sonali

@prashant1603765 @sonaliaggarwal47


I could not see Find Files and Folder activity under microsoft 365
Can you please assist me thanks.

@TJamuna

Can you try with path exists activity

if it wont work then follow,
And try to use Get file or folder activity, and validate the output.

  • Use the Get File/Folder Activity:
  • Inside the Office 365 Scope, use the Get File/Folder activity.
  • Configure it to fetch a folder from SharePoint by specifying the path or ID of the folder.
  • Check If Folder Exists:
  • If the folder exists, the activity will return the folder’s metadata.
  • If it doesn’t exist, it will throw an error, which you can catch using a Try-Catch activity.

Happy automation!!

@TJamuna,

The Find File and folder activity is deprecated. We will have to use alternative that is

For Each file/Folder activity

1 Like

@TJamuna,

What option do you have to check if folder exists from this list?

1 Like

@ashokkarale thanks for the reply
Relative path or folder picker

Can you please assist me.

here you need to use for each file or folder to get the folders info as @ashokkarale suggested.
Give a try on both, from which option you are able to get the folder info.
if didn’t work both try other options also

Hi @TJamuna ,

please check once,

@TJamuna,

Follow these steps:

Assuming your SharePoint folder structure is like this

You are checking Child folder exists.

  1. Navigate to Parent folder in browser
  2. Take the URL before &viewid
    image
  3. Use Get Files or Folders activity and put the URL from step 2 into File or folder URL property. Declare a variable to store output from the property. I have declared it as result.


4. Now Use For Each activity and If condition inside it to check if any folder have the same name as desired. If found - Folder exists else it doesn’t.

Hope this is clear.

2 Likes

@ashokkarale
Let me try. Thanks for the reply

1 Like

@ashokkarale
Its working, Thanks for the support.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.