deleting a folder inside gcp bucket

Solution 1:

There is no such thing as folder in the GCS at all. The "folder" - is just a human friendly representation of an object's (or file's) prefix. So the full path looks like gs://bucket-name/prefix/another-prefix/object-name. As there are no folders (ontologically) - thus - there is nothing to delete.

Thus you might need to delete all objects (files) which start with a some prefix in a given bucket.

I think you are doing everything correctly.

Here is an old example (similar to your code) - How to delete GCS folder from Python?

And here is an API description - Blobs / Objects - you might like to check the delete method.