I am using Python
client for google drive API.
I want to enumerate folders that has a name that does not start with a dot ('.').
My naive query to find the folders looks like this:
query = f"""
{root_folder_id}' in parents
and mimeType = '{FOLDER_MIMETYPE}'
and trashed = false
and not name contains '.'
"""
The reason I used the contains
operator here is because it is stated in the official documentation quote:
The contains operator only performs prefix matching for a name term. For example, suppose you have a name of HelloWorld. A query of name contains 'Hello' returns a result, but a query of name contains 'World' doesn't.
My query does not work. It does not find any folders. If I remove the offending last part and not name contains '.'
then it finds all folders, including those with a dot at the start of the name, so I have narrowed it down to this part.
How can I solve this?
Suggestion:
You can try this other approach to enumerate folders that have a name that does not start with a dot ('.').
Fetch all the folders from a parent folder and then filter the result using python list comprehension to get all folders that do not start with dot.
Code
Output:
Parent Folder on Google Drive:
References:
List Comprehension
Method: files.list