138

In Google Drive, you can use Sort split-button and choose Quota Used to show the size of each file there.

However, folder sizes are not shown.

I guess it's really a basic requirement in order to manage folders in Google Drive. I have a folder full of subfolders and files, and I can't go summing up the size of each file recursively.

I need to decide whether deleting this folder or not. But I need to know it's size beforehand.

Is there any way to see how much volume a folder has taken?

8
  • 2
    The Google Drive File Stream app will tell you the size of a google drive / team drive folder. You don't even need to sync the folder. On Mac just "Get Info" on the folder and it will load the complete size of the folder
    – moof2k
    Dec 22, 2018 at 0:12
  • If that Google Drive has been mirrored to your disk you can use tools such as wiztree, windirstat... to quickly view the size of all folders and subfolders.
    – skan
    May 14, 2019 at 17:53
  • @Rubén Nope it doesn't.
    – Aditya
    Sep 10, 2020 at 17:16
  • I've posted an answer below, that worked for me!
    – Aditya
    Sep 10, 2020 at 17:19
  • 1
    I don't have the required reputation!
    – Aditya
    Sep 11, 2020 at 6:33

9 Answers 9

39

UPD: as Google started to block unverified scripts, the only way to use it is copy-paste the source to your script editor. And verification requires some extra effort, so I didn't do it yet.

UPD2: if you have a lot of files it will reach the execution time limit and stop; you will need to run it multiple times (you can also set up automatic timed trigger for this)

I wrote a simple script for this. You can run it from here: https://script.google.com/macros/s/AKfycbyUvNoXzBMBDE9pnHkLUltliGwjip5x09t3PeTY_1KoXO45F6iz/exec

(if it gets stopped, just run it once again, and it will continue from where it left)

It will create two files in the root of your Drive, one displays progress and is deleted after script is completed. Other is the report which lists all folders and sizes. It looks like this.Google Drive folder sizes report

Or you can just copy and paste the code into Google Script editor and run "doGet()" function from there:

function doGet(){
  var progressFileCompletedFound = DriveApp.getRootFolder().searchFiles("title contains 'Folder Sizes Report Completed'");
  if(progressFileCompletedFound.hasNext()) {
  return ContentService.createTextOutput("Report file was already created in your Drive's root folder, exiting.");
  }
  CreateReportFile();
  DriveApp.createFile("Folder Sizes Report Completed.txt", "You may safely delete this file.");
  return ContentService.createTextOutput("Report file created in your Drive's root folder");
}

function CreateReportFile() {
  var reportContent = CreateReport();
  DriveApp.createFile('Folder Sizes Report.txt', reportContent);
}

function CreateReport(){
  var reportContent = "";
  var progressFileFound = DriveApp.getRootFolder().searchFiles("title contains 'Getting Folder Sizes,'");
  var progressFile;
  var report=[];
  if(progressFileFound.hasNext()) {
      progressFile = progressFileFound.next();
      var json = progressFile.getBlob().getDataAsString();
      try{
        report = JSON.parse(json);
      } catch(Exception) {
         DriveApp.removeFile(progressFile);
         progressFile = DriveApp.createFile("Getting Folder Sizes, 0 processed...", " ");
      }
    }
  else {
      progressFile = DriveApp.createFile("Getting Folder Sizes, 0 processed...", " ");
    }
  var f = DriveApp.getRootFolder();
  AddFolderToReport(report, f, "/", progressFile);
  DriveApp.removeFile(progressFile);
  reportContent += "TotalSize MB   FilesSize MB   Path \r\n";
  for(var i=0; i<report.length; i++)
    reportContent += Utilities.formatString("%12.2f ", (report[i].totalSize / (1024*1024))) + Utilities.formatString("%11.2f      ",(report[i].filesSize / (1024*1024))) + report[i].folderPath + "\r\n";
  return reportContent;
}

function AddFolderToReport(report, currentFolder, currentPath, progressFile){
  var report1 = [];
  for(var i=0; i<report.length; i++)
    if(report[i].folderPath == currentPath)
       return report[i].totalSize;

  var fChildren = currentFolder.getFolders();
  var totalSize = 0;
  while(fChildren.hasNext() && currentPath.length < 2000){
    var nextF = fChildren.next();
    totalSize += AddFolderToReport(report, nextF, currentPath + nextF.getName() + "/", progressFile);
  }
  var filesSize = 0;
  var files = currentFolder.getFiles();
  while(files.hasNext()){
    filesSize += files.next().getSize();
  }
  totalSize += filesSize;
  report.push({folderPath: currentPath, filesSize: filesSize, totalSize: totalSize});
  progressFile.setName("Getting Folder Sizes, " + report.length + " processed...");
  progressFile.setContent(JSON.stringify(report));
  return totalSize;
}

UPD: the script was updated so that if it runs too long and is stopped, just run it once more and it will resume from where it left, using data stored in "Getting Folder Sizes ..." file.

1
22

Update 2020

Nowadays, clicking on n GB of nn GB used takes us to the list of biggest files on our Drive:

end update



Not by folders but great to find where are the big files, thanks to this pretty hat tip: Sort your Google Drive Files by Size to Find the Biggest Files.

On GDrive left panel, hover Upgrade storage:

where to click

Now click that i at the right of Drive, and there we have it:

showing biggest files This is the direct link for that: https://drive.google.com/drive/quota

5
  • 36
    it shows only files not folder
    – shareef
    Sep 14, 2016 at 10:30
  • 7
    Do you sell apples? Yes, we sell apples. Here is an orange.
    – mchid
    Mar 2, 2021 at 10:54
  • 1
    In my case this number is about a quarter of actual size....
    – Mamrezo
    May 16, 2021 at 10:05
  • this is not an answer, and there are answers in this thread, so please remove this and create a comment. May 2, 2022 at 21:21
  • @AlexAngelico, I'm at loss how should I convert an illustrated answer into a comment. Thanks for your input though.
    – brasofilo
    May 6, 2022 at 5:21
20
+500

You can use Python. This answer was inspired by Aditya, so please upvote his answer there. I provide improved code below, which can display only the largest folders. (It is my first time coding in Python!)

In Google Colab, create a new notebook, click on the "Files" icon in the left sidebar, and "Mount Drive". You will need to authenticate the Google Drive File Stream to access your Google account, and copy the authentication token into the Colab notebook.

Then, run this code:

import re
all = open("all.txt", "w")
! du -h /content/drive/My\ Drive/* >> all.txt
all.close()
GB = open("GB.txt", "w")
for line in open("all.txt", "r"):
    if re.search("G\t", line):
        GB.write(line)
        print(line)
GB.close()

All the folder sizes will be saved in "all.txt". Note that the -h option (as opposed to -sh) displays sub-folders. Then, "G\t" is the string which is searched for (a capital G, followed by a tab), and that line is printed. That isolates the folders which are at least 1GB large. (You could use "M\t" for folders with a megabyte size.) These largest folders are stored in "GB.txt".

1
11

One approach to this is using Google Colab.

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

Step 2: Mount drive by running this code in a cell:

from google.colab import drive
drive._mount('/content/drive')

This will provide you an url to obtain an authorization code, which you will need to provide in a box.

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

Output:
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/*

Output:
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/

Edit: drive.mount has been changed to drive._mount

10
  • /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, 2020 at 16:59
  • 1
    well, it worked! now i hope we can find out a way to properly redirect the reward...
    – cregox
    Sep 12, 2020 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, 2020 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, 2020 at 8:25
  • Well, /content/drive/My\ Drive/ gives you access to the root folder of your drive.
    – Aditya
    Sep 15, 2020 at 11:12
9

Unfortunately, the answer is no.

See this discussion: http://productforums.google.com/forum/#!topic/drive/TVtw1_QA6fA

2
  • I think this is more or less the answer, depending on how to interpret OP's question — using Google Drive's website? Definitely no. But in the end, he asked: "Is there any way to see how much volume a folder has taken?". Well, within the "any way", yes. You can use the GDrive API to add up file sizes recursively; you can also use the script made from another answer in here, third party software, etc. Dec 14, 2019 at 1:13
  • 2
    Google Drive File Stream, the "business" option on the download website, will show you Folder sizes on your computer locally fairly quickly. i.imgur.com/7JuL3Jf.png
    – Ray Foss
    Apr 1, 2020 at 23:07
5

Update, september 2020:

There is now an Android app that can do this for you, called Storage Analyzer & Disk Usage,

It gives you a detailed tree of the entire folder hirearchy, just like WinDirStat on Windows or (KDirStat on GNU/Linux or Disk Inventory X on macOS).

This is what it looked like when I ran it:

enter image description here

If you do not have access to an Android device, there are many Android emulators for desktop and even in-browser ones (proceed with caution on the latter, as you will have to sign in with your Google-account on a system you do not have control over.)

Beware: Apparently this app has a design flaw, it will need to be in the foreground constantly while it runs its analysis (which can take some time if your Google Drive folder has a lot of content.)

11
  • One would need to copy the contents in order to own the files, but that is infeasible if there are multiple folders inside the parent folder in question.
    – ahorn
    Apr 30, 2019 at 4:30
  • @ahorn You can copy a folder with subdirectories in Drive.
    – Fiksdal
    Apr 30, 2019 at 4:32
  • @Revetahw how does one do that? When I right-click a folder, there is no option to "Make a copy" as with files.
    – ahorn
    Apr 30, 2019 at 15:14
  • 2
    @ahorn Wow, you're right
    – Fiksdal
    May 1, 2019 at 3:24
  • 1
    @cregox Oh, so this app will stop its processing if you even switch to another app in the middle of the process? That is rather annoying, although I guess I did not notice since my process was so fast that I did not have time to switch to another app. I guess a decent solution would be to run this app on an Android emulator (or a virtualized Android-within-Android) so that the app thinks it is always in the foreground, even if you need to use your Android-device for something else while it is processing. That way the long processing time can be acceptable.
    – Fiksdal
    Sep 6, 2020 at 19:51
4

I was also looking for way to list folder and file sizes so that I can do clean up on my G Drive. I actually found quite an accurate way of doing it.

  • Download and install Drive File Stream from Google
  • After installation, sign into your Google account using the Drive File Stream app.
  • It'll add your Google Drive as a drive on your PC enter image description here
  • Download and install WinDirStat
  • Open WinDirStat and then select the Google Drive added by Drive File Stream
  • Scan the drive and viola. It even shows the date and time of the last change enter image description here

(Credits go to this guy for introducing me to Drive File Stream: https://support.google.com/drive/thread/3970069?hl=en&msgid=86820802)

0
3

If you have Google Drive installed on your PC or MAC, use Windows Explorer (PC) or Finder (MAC) to easily check the folder sizes. I could not find a way to do it from a web browser.

2
  • 2
    The folders that I've selected for Google drive on my PC amount to >6 GB. However google drive website says they are only 3.7 GB (fully synched). Would be nice to check folder sizes/no files within etc as I'm not convinced all my files are synched!
    – user56353
    Jan 5, 2014 at 11:51
  • 1
    @user56353 PCs will sometimes report the disk space used. Disk space is allocated in whole blocks, like 4k in size, and if a file is only 1k, it still uses 4k on disk. Thousands of small files could use up lots of wasted space. Google Drive might report only actual file size. Also Google Drive may compress photos & videos, or de-duplicate files between users if they are the same file. Check actual file size vs. size on disk. Windows 8.1 reports both in File Properties (ALT+ENTER).
    – Chloe
    Sep 29, 2017 at 17:20
2

If you use Linux,

  1. Mount your Google Drive account as a network drive on your computer, using the google-drive-ocamlfuse package (in Alessandro Strada's PPA). Note: the files will not be downloaded (unless you open them), so this method won't use much of your data allowance.

  2. Save the folder hierarchy, with sizes, as a text file. I recommend you only inspect the folders bigger than 1GiB, as that makes it easier to find the biggest folders (in case you want to reduce disk space):

    cd "/home/username/Google-Drive"     # (or wherever the drive is mounted)

    tree --du -h | grep G] > "tree.txt"

    where you may want to be more specific about where the .txt file is stored.

    Note: be patient with the tree command. If you have a lot in storage, it will take a while.

  3. Print out the text file, inspect and enjoy!

4
  • this was quite promising, but someone else came up with a much simpler solution, from my point of view: webapps.stackexchange.com/questions/146178/…
    – cregox
    Sep 12, 2020 at 20:31
  • 1
    @cregox you linked the question but not the answer that you think is better Feb 25, 2021 at 6:25
  • @jelliclecat sorry. but i'll leave the challenge for you to figure it out. there's only 1 right answer to "which one i meant". 😁
    – cregox
    Mar 3, 2021 at 19:58
  • For anyone wanting a more GUI solution, baobab - the standard ubuntu disk usage analysis tool works quite well with fuse mounted google drives.
    – Tejas Kale
    Jun 4, 2021 at 10:28

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