How to find folder using Google Drive Find Files and Folder activity

Hi, I’m trying to return the folder ID of a specific folder.
I know the parent folder ID but then want to return the folder relating to the current year within this folder. If the folder doesn’t exist I then need to create one.

How can I find a folder ID following a path. Due to the way folders are structured there are many folders with similar names but organised under sub-folder.

Eg, I have RootFolderID and want to find "RootFolderID\2022". If 2022 folder doesn’t exist then create folder.

Any help would be great. thanks!

Hi @Shane_Curran

Check out this video link

Regards
Gokul

HI @Shane_Curran

  • Get the root folder id
    image
  • Get the files and folder available inside the folder
"'" + FolderId + "' in parents and name contains '*'"

  • if condition will be like
ListFilesinFolder.AsEnumerable().Where(Function(s) s.MimeType.Contains("application/vnd.google-apps.folder")).Select(Function(a) a.Name).ToString.Contains("2022")
  • True-> Empty and False-> Create Folder

Checkout this workflow
Main.xaml (22.8 KB)

Regards
Sudharsan

1 Like

Thanks! Worked perfectly!

Hi, sorry was a bit pre-emptive there. This works if the folder does not exist, but the if statement seems to still be creating folders even if a folder of the same name exists. Any ideas how to fix that? Thanks!

HI @Shane_Curran

Change this condition there

String.Join(",",ListFilesinFolder.AsEnumerable().Where(Function(s) s.MimeType.Contains("application/vnd.google-apps.folder")).Select(Function(a) a.Name)).Contains("2022")

Note: If you delete a folder or a file make sure you delete them in the Trash too else it is getting that folder also in consideration

Adding this thread if you need assistance in deleting trash checkout this

Regards
Sudharsan

1 Like

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