Colab: Google Drive folder to json
Description
I was thinking to myself the other day: “Wouldn't it be nice if I had a tool that makes a json over a Google Drive folder?”.
And then I Google it. Only to see pages and pages of different types of implementations appearing. But all of them seemed kinda kludge (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 (Open in a new tab is recommended)
-Open the Parameters List
The Iframe below may not work. Prefer open 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 return 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 it's limitations. Although, all those limitations can be contoured case-by-case.
*The more files you have in the folder, the more the processing will take to finish it
Example
Bye.
Comentários
Postar um comentário