Easily Check the Directory Size in Google Drive

Panji Brotoisworo
4 min readAug 5, 2020

A guide for the non-programmer

Google Drive and Google Colab

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:

  1. Open Google Colab
  2. Upload the provided notebook
  3. 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:

You will see this window when opening Google Colab. Press the “Upload” tab which is highlighted in the image

In the tab, upload the notebook that was provided. Once it is done uploading it should look like this:

Notebook is now uploaded

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.

Running the cell will result in this prompt
Permissions required for Google Colab to access your Google Drive. Click “Allow”
Copy and paste the code that is given (Note: I censored most of mine to be safe)

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:

Successful Google Drive mount

You should also have a new yellow folder in your Google Drive. This is where your Colab notebooks will be stored.

Drive’s folders are grey by default. Colab notebooks are stored in a yellow folder.

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.

--

--

Panji Brotoisworo

Researcher working on geospatial sciences and general programming