Colab: Google Drive folder to json

Now you can have a Json file of your drive folder structure with this Google Colab project


Description

I was thinking to myself the other day: “Wouldn't it be nice if I had a tool that makes a json of a Google Drive folder?”.
And then I Googled it. Only to see pages and pages of different types of implementations appearing. But all of them seemed kinda kludgy (not that this is not the case with this tool too, but…)

So I did what all the programmers complain about other programmers. I reinvented the wheel. With Colab & Python.

You can have a JSON file of your drive folder structure with this Google Colab project.

Example link: https://drive.google.com/drive/folders/120dv78Hzo52KmI92LfQYeibdv60PHYeJ

How to start:
-Make a copy of it (Opening in a new tab is recommended)
-Open the Parameters List

The Iframe below may not work. Prefer opening in a new tab.



How to use it:

   - Change folder permission to public
   - Copy the folder's id in the URL
   - Add the output folder
   - Add the name of the output file
   - Click play in 1, 2, 3, 4 and 5 respectively

And you're done.

The output will be something like this:

File Id: 17TwIJhnGNYqeWfWbqxLDp3F2s8Ekgbaq 
Preview: https://drive.google.com/file/d/17TwIJhnGNYqeWfWbqxLDp3F2s8Ekgbaq/view 
Direct Link: https://docs.google.com/uc?export=view&id=17TwIJhnGNYqeWfWbqxLDp3F2s8Ekgbaq

Be aware::
    It will prompt a Google authentication window, for it to read your Drive
    If you update the folder structure, you can rerun the code. It will update the file, maintaining the same output link.

Important info:
- You may find a CORS error / crossdomain error, while obtaining this as a REST request. because normal users can't have access to HTTP parameters. Thus, acknowledge that this method has its limitations. However, all those limitations can be addressed case-by-case.

*The more files you have in the folder, the longer the processing will take to finish.

Example

*May not work due to changes on Google's CORB / CORS policy


If you find it useful, don't use it for piracy. Please.

Bye.

Popular posts from this blog