Easily Check the Directory Size in Google Drive
A guide for the non-programmer
One of the drawbacks of Google Drive is that you cannot see how big a folder is. This can create problems when you want to download a subset of your cloud data but you are not sure how much space to allocate for your download. This can be done using Google Colab, Google’s free online coding platform. This tutorial will guide you on how to setup Google Colab and how to run the notebook file that is used to calculate a directory size.
Download the notebook for Colab here:
https://drive.google.com/file/d/1sKL22iwKdFFPf3h9yj3Qdha7Gkgfiffo/view?usp=sharing
All you have to do is:
- Open Google Colab
- Upload the provided notebook
- Enter the path into the easy-to-use widget
Let’s go over the steps in detail below.
Open Google Colab and Upload the Notebook
Go to the Google Colab website here:
colab.research.google.com/
You will be greeted by this window:
In the tab, upload the notebook that was provided. Once it is done uploading it should look like this:
Google Colab does not always have access to your Google Drive. It has to be mounted first and this has to be done every time you start up the notebook. This is a simple process. Mouse over the cell containing the text. This will make the run button appear. Click the “Run” button. Or for the people more familiar with Jupyter Notebooks, select the cell and press Ctrl+Enter to run it.
Once you run it it will ask for a code to authorize access to your Drive. You need to click the link and allow permissions.
Copy and paste the authorization code into the prompt. If it is successful then your drive should be mounted and the cell should look like this:
You should also have a new yellow folder in your Google Drive. This is where your Colab notebooks will be stored.
How to Find the Directory Path and Calculate Directory Size
Once it is mounted you can access your drive using the explorer. Click the folder icon and navigate to the folder you want to check the file size of. Right click on the folder and click “Copy Path”.
Paste the path into the form. Select your output unit from the drop down list. Then click the run button it should show you the size of the folder in your specified unit.
Opening the Notebook Again
Click the notebook which should open the preview window. Click the option to run it with Google Colaboratory at the top to launch the notebook in Google Colab. Remember that you have to mount your Google Drive every time you open the notebook.