How to check whether a Folder/Subfolder is present in Google drive

Hi Experts,

I have a use case where I need to check whether a folder Regionand under this folder the sub folders /BusinessUnit/Account are present in Google drive. If yes no need to create. If No, need to create. How can I proceed with this case. I tried Folder Exist activity but it did not work.

1 Like

@dutta.marina

Google activities are separate.You should be using find files or folder and check if any folders are returned result.count>0 …if yes then folder is present if no you can use create folder activity

Copy file

For full range of activities

Hope this helps

Cheers

Hi @dutta.marina

Folder Exist is to check the local file system whether the folder is exist or not, this is not for Gdirve

For Gdrive you have to download the package Google WorkSpace
image

Once downloaded you can try with the activities that are available
image

Hope this may help you

Thanks,
Srini

Hi have downloaded the GSuite application. I am able to create folders. But I need to put a condition before creating folder in Gdrive that whether that particular folder exsist or not? For that how shall i proceed

@dutta.marina

As specified use find files or folder activity

Cheers

Hi Anil ,

I tried your method using count. But its not working. Attached the workflow. Please review nd let me know.
Google_Sheets.7z (1.3 MB)

Hi @dutta.marina Check below links

Hey @dutta.marina ,

Check the below link.

Thanks,
Sanjit

@dutta.marina

either use Result.ToArray.Count>0 or Result.Length>0 …I just saw the count is not defined for file[] type

Hope this helps

cheers

Hi Usha,

I was able to create folder and sub folder . I need to check whether those folders exist or not in Gdrive .

Thank You

@dutta.marina Check the below video. Does it not helpful

Hi Anil,

Thank You for the help. I will try and let you know.

Thanks

1 Like

Hi Anil,

Can you please share the sample code of Result.ToArray.Count>0 or Result.Length>0.

What I have done is I first used
1)Find files and folder activity
2)Output I stored in variable result.
3)Used assign activity . folder =result.Count().ToString
4)If result.ToArray.Count>0
Donot create folder else create folder
Is this correct ?I did not get this part. count is not defined for file[] type

1 Like

I am not sure What this is for…

But yes remaining is correct…

result.count was not giving result because count is kind of a method in the class …and in the file class this count method is not there…so we are converting that to array and then trying to get the count

Hope this helps

cheers

But it is not checking If condition . Its creating new folder.

I gave in If condition result.ToArray.Count>0, but its not checking the If condition. Everytime its creating new folders. Can you help on this?

@dutta.marina

Are you getting any results from teh find files or folder?

can you add break point after find files and check the data from locals panel

I guess your search itself is failing…can you properly search or show the search what you are performing

cheers

Hi Anil,

I am getting the output.
I had initially was searching wrong file name.

1 Like

@dutta.marina

I hope the issue is resolved now…You can mark solution and close so that others also can get help…else happy to help

cheers

Hi Anil,

The issue is resolved r one folder. Now I have multiple subfolders under main Out_Folder. At that time when checking m,ultiple subfolder conditions how we should do. I have attached my code. Please check and let me know.[G-Suite (3).zip|attachment](upload://qaIniMA2jD0Vh9nDRButo2IHR38.zip) (5.0 KB)

The issue is resolved r one folder. Now I have multiple subfolders under main Out_Folder. At that time when checking m,ultiple subfolder conditions how we should do. I have attached my code. Please check and let me know
G-Suite (3).zip (5.0 KB)