How to list all subfolders and files on a folder in Google Drive Node?

I have a Google Drive folder called “Cars” with many subfolders. Inside the subfolders I have many .pdf files. Is there a way to list all the subfolders and files using just one Google Drive Node. Actually I have two, the first list all my folders and other look for files in each of them. It works but I wonder if there’s a more efficient way of doing this.

Thanks you guys are the best.

Hey @Luiz_H_Monticelli welcome to the community.

You can achieve this with a single Google Drive node using the “Search” option. Set the node to search for files and folders within the “Cars” folder, and use a query like 'root_folder_id' in parents replace root_folder_id with the actual ID of your “Cars” folder.

This will return a list of all files and subfolders within the “Cars” folder. You can then use the mimeType field to differentiate between folders application/vnd.google-apps.folder and files.

Give it a try!

Pardon my ignorance, but I’ve tried many ways.

Something like this?

Not exactly, the method proposed requires you to change the Search Method to be changed to Advanced Search, like this

Unfortunately, this method doesn’t allow recursively getting all the file from that a given root folder. If you need to get all file recursively (multiple levels of nesting) you cannot get away with just a single node.

2 Likes

This is what I thought. It’s working well with two nodes, however it seems inefficient. I had a major argument with ChatGPT about that since it was telling me I could do that in one node. Please let me know if someone can figure that out. Thank guys.

Check out this example I made recently to see how you can recursively collect all files from the given folder id, just in case you want ideas.

1 Like