You can look up file sizes on Google drive but it does not show the size of the whole folder.

I've been looking for ways to get the size of a folder on Google Drive but couldn't find any.

Is there any way to see how much space a folder has taken on Google Drive?

  • 2
    Does this answer your question? How to view the folder size in Google Drive? – Rubén Sep 10 at 17:04
  • @Rubén Nope it doesn't. – Aditya Sep 10 at 17:16
  • I've posted an answer below, that worked for me! – Aditya Sep 10 at 17:19
  • Post the answer in the referred question. There is a 500 bounty that expires in 2 days!! – Rubén Sep 10 at 17:24
  • 1
    I don't have the required reputation! – Aditya Sep 11 at 6:33

One approach to this is using Google Colab.

Step 1: Visit Google Colab and create a new python 3 notebook.

Step 2: Mount drive

mount drive

Step 3: run this code in the cell: (replace folder-name with any folder in your drive)

! du -sh /content/drive/My\ Drive/<folder-name>

For example, to get the total size of the /content/drive/My\ Drive/dataset directory, you would run the following command:

! du -sh /content/drive/My\ Drive/dataset

3.4G    /content/drive/My Drive/dataset

if you want to display the disk usage of the first-level subdirectories, run:

! du -sh /content/drive/My\ Drive/dataset/*

24K     /dataset/db
3.3G    /dataset/lib
4.0K    /dataset/local
108.0M  /dataset/lock
856.0M  /dataset/log

For more details on du command, visit: https://linuxize.com/post/how-get-size-of-file-directory-linux/

| improve this answer | |
  • /dataset didn't work for me. taking it out seem to work... the first 2 steps are quite confusing from my brief experience now trying to replicate them. waiting for at least 15 minutes for the task to complete or even reach any folder to show up. – cregox Sep 12 at 16:59
  • 1
    well, it worked! now i hope we can find out a way to properly redirect the reward... – cregox Sep 12 at 20:25
  • big caveat: it'll consider all kinds of files, regardless if it's counting against the quota or not. i don't think there's any way around it. – cregox Sep 12 at 21:44
  • 1
    this is my favourite one liner, so far: ! cd /content/drive/My\ Drive/ ; du --apparent-size -csh * | sort -rh – cregox Sep 13 at 8:25
  • Well, /content/drive/My\ Drive/ gives you access to the root folder of your drive. – Aditya Sep 15 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.