Home » How to view the folder size in Google Drive?

How to view the folder size in Google Drive?


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.");
  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();
        report = JSON.parse(json);
      } catch(Exception) {
         progressFile = DriveApp.createFile("Getting Folder Sizes, 0 processed...", " ");
  else {
      progressFile = DriveApp.createFile("Getting Folder Sizes, 0 processed...", " ");
  var f = DriveApp.getRootFolder();
  AddFolderToReport(report, f, "https://webapps.stackexchange.com/", progressFile);
  reportContent += "TotalSize MB   FilesSize MB   Path rn";
  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 + "rn";
  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() + "https://webapps.stackexchange.com/", progressFile);
  var filesSize = 0;
  var files = currentFolder.getFiles();
    filesSize += files.next().getSize();
  totalSize += filesSize;
  report.push({folderPath: currentPath, filesSize: filesSize, totalSize: totalSize});
  progressFile.setName("Getting Folder Sizes, " + report.length + " processed...");
  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.

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

Unfortunately, the answer is no.

See this discussion:

Related Solutions

Building a multi-level menu for umbraco

First off, no need pass the a parent parameter around. The context will transport this information. Here is the XSL stylesheet that should solve your problem: <!-- update this variable on how deep your menu should be --> <xsl:variable...

How to generate a random string?

My favorite way to do it is by using /dev/urandom together with tr to delete unwanted characters. For instance, to get only digits and letters: tr -dc A-Za-z0-9 </dev/urandom | head -c 13 ; echo '' Alternatively, to include more characters from the OWASP...

How to copy a file from a remote server to a local machine?

The syntax for scp is: If you are on the computer from which you want to send file to a remote computer: scp /file/to/send username@remote:/where/to/put Here the remote can be a FQDN or an IP address. On the other hand if you are on the computer wanting to...

What is the difference between curl and wget?

The main differences are: wget's major strong side compared to curl is its ability to download recursively. wget is command line only. There's no lib or anything, but curl's features are powered by libcurl. curl supports FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP,...

Using ‘sed’ to find and replace [duplicate]

sed is the stream editor, in that you can use | (pipe) to send standard streams (STDIN and STDOUT specifically) through sed and alter them programmatically on the fly, making it a handy tool in the Unix philosophy tradition; but can edit files directly, too,...

How do I loop through only directories in bash?

You can specify a slash at the end to match only directories: for d in */ ; do echo "$d" done If you want to exclude symlinks, use a test to continue the loop if the current entry is a link. You need to remove the trailing slash from the name in order for -L to...

How to clear journalctl

The self maintenance method is to vacuum the logs by size or time. Retain only the past two days: journalctl --vacuum-time=2d Retain only the past 500 MB: journalctl --vacuum-size=500M man journalctl for more information. You don't typically clear the journal...

How can I run a command which will survive terminal close?

One of the following 2 should work: $ nohup redshift & or $ redshift & $ disown See the following for a bit more information on how this works: man nohup help disown Difference between nohup, disown and & (be sure to read the comments too) If your...

Get exit status of process that’s piped to another

bash and zsh have an array variable that holds the exit status of each element (command) of the last pipeline executed by the shell. If you are using bash, the array is called PIPESTATUS (case matters!) and the array indicies start at zero: $ false | true $...

Execute vs Read bit. How do directory permissions in Linux work?

When applying permissions to directories on Linux, the permission bits have different meanings than on regular files. The read bit (r) allows the affected user to list the files within the directory The write bit (w) allows the affected user to create, rename,...

What are the pros and cons of Vim and Emacs? [closed]

I use both, although if I had to choose one, I know which one I would pick. Still, I'll try to make an objective comparison on a few issues. Available everywhere? If you're a professional system administrator who works with Unix systems, or a power user on...

How do I use pushd and popd commands?

pushd, popd, and dirs are shell builtins which allow you manipulate the directory stack. This can be used to change directories but return to the directory from which you came. For example start up with the following directories: $ pwd /home/saml/somedir $ ls...

How to forward X over SSH to run graphics applications remotely?

X11 forwarding needs to be enabled on both the client side and the server side. On the client side, the -X (capital X) option to ssh enables X11 forwarding, and you can make this the default (for all connections or for a specific connection) with ForwardX11 yes...

What does “LC_ALL=C” do?

LC_ALL is the environment variable that overrides all the other localisation settings (except $LANGUAGE under some circumstances). Different aspects of localisations (like the thousand separator or decimal point character, character set, sorting order, month,...

What is a bind mount?

What is a bind mount? A bind mount is an alternate view of a directory tree. Classically, mounting creates a view of a storage device as a directory tree. A bind mount instead takes an existing directory tree and replicates it under a different point. The...

Turn off buffering in pipe

Another way to skin this cat is to use the stdbuf program, which is part of the GNU Coreutils (FreeBSD also has its own one). stdbuf -i0 -o0 -e0 command This turns off buffering completely for input, output and error. For some applications, line buffering may...

Can less retain colored output?

Use: git diff --color=always | less -r --color=always is there to tell git to output color codes even if the output is a pipe (not a tty). And -r is there to tell less to interpret those color codes and other escape sequences. Use -R for ANSI color codes only....

How do I copy a folder keeping owners and permissions intact?

sudo cp -rp /home/my_home /media/backup/my_home From cp manpage: -p same as --preserve=mode,ownership,timestamps --preserve[=ATTR_LIST] preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links,...

Can I zip an entire folder using gzip?

No. Unlike zip, gzip functions as a compression algorithm only. Because of various reasons some of which hearken back to the era of tape drives, Unix uses a program named tar to archive data, which can then be compressed with a compression program like gzip,...