120

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?

2
  • 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 '18 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 '19 at 17:53
32

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.

38
  • 1
    Great script but I have been unable to authorize it either through the link or running straight from scripts.google.com. After agreeing on the permissions, I loop back to the login for authorization. Jan 27 '19 at 11:01
  • 1
    Not sure why, I've tried on friend's account and it is working. Looks like generic problem with your account, or maybe it's just browser cache? Try using anonymous window (Ctrl+Shift+N) Jan 28 '19 at 14:16
  • 5
    @jj. I have updated the script so it can now resume from where it stopped. Just run it few times. Feb 1 '19 at 23:30
  • 3
    Great work on the script! I couldn't get the link to work but was able to copy and paste the code into Google App Scripts and run it. I had to restart it a few times because of Google's timeout restriction but it finally worked in the end. Thank you!
    – frakman1
    Mar 11 '19 at 17:30
  • 1
    @ahorn Yes, the script looks for every file and folder under "/" path, which is "My Drive". You can see size of any subfolder under "/", but what is the path for your "computer" - I don't know. You can try to modify this line: var f = DriveApp.getRootFolder(); which tells where to start. May 3 '19 at 18:06
20

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

3
  • 30
    it shows only files not folder
    – shareef
    Sep 14 '16 at 10:30
  • 2
    Do you sell apples? Yes, we sell apples. Here is an orange.
    – mchid
    Mar 2 at 10:54
  • 1
    In my case this number is about a quarter of actual size....
    – Mamrezo
    May 16 at 10:05
8

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 '19 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 '20 at 23:07
8
+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".

15
  • 1
    i hope you can find a way to share the bounty with @aditya - i got an email from them about their answer, and they said they're just happy it could be useful... also, nice work with quick python learning! issues... 1. the du takes a very long time to finish in my case (just about 200gb) both here and in his simpler script of course. perhaps you can improve the python to account for this and be more gradual. 2. there's an issue around following symlinks which is harder to deal with: if it follows too many, the numbers will be wrong. 3. ideally, i want to see quota usage. different beast!
    – cregox
    Sep 13 '20 at 10:41
  • finally, 4. very interesting idea on using files to keep state... but >> probably won't work as you intended, as it's a simple append and running the code again won't continue from where it stopped, but rather just run again. i wanted to estate again: thanks so much for your efforts!! it's usefull as it is (even while i'm still waiting to see the actual result, i can already imagine how good it will be) 😁😘
    – cregox
    Sep 13 '20 at 10:44
  • Thank you. I think the running time is to do with the cloud computing power in Colab. I was surprised to see that Aditya couldn't leave an answer to this question two days ago (see the privileges page). Perhaps there is a restriction on this question I can't see. There was 6 hours left of the bounty grace period, and a lot of free rep up for grabs! I did improve his code suggestion somewhat, but, future readers, please upvote Aditya's post. At least he says he's happy with it.
    – ahorn
    Sep 13 '20 at 10:52
  • By "quota usage" are you talking about the percentage it takes up out of the total Drive space, or are you talking about getting a list of the largest individual files?
    – ahorn
    Sep 13 '20 at 10:56
  • 1
    up to this date, i'm still working on cleaning up my drive, and this script worked really well. with all its defects, helped me immensely since there's just nothing else that even works! that being said, i did made a small modification in it for making it easier to see the results. i think it'll be easier to propose an edit.
    – cregox
    Dec 16 '20 at 21:37
4

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 '19 at 4:30
  • @ahorn You can copy a folder with subdirectories in Drive.
    – Fiksdal
    Apr 30 '19 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 '19 at 15:14
  • 2
    @ahorn Wow, you're right
    – Fiksdal
    May 1 '19 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 '20 at 19:51
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.

6
  • 1
    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 '14 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 '17 at 17:20
  • 1
    In our case, we're using Drive File Stream, and wanted to check the size of the folder prior to synchronizing it to the local machine. Mar 11 '19 at 18:06
  • 1
    @mm32993 This answer isn't useful, because in my situation I want to check the amount of storage a large folder (up to 80GB) is taking up without synchronising it.
    – ahorn
    Apr 30 '19 at 4:37
  • 1
    @ahorn I think you missed the context. Drive File Stream does not download items, thus we can not see the full size of the folder. We would like to synchronize everything from a specific folder in order to prepare to work offline, but we're unable to see the size of the folder prior to doing so. :) Apr 30 '19 at 18:00
1

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 '20 at 20:31
  • 1
    @cregox you linked the question but not the answer that you think is better Feb 25 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 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 at 10:28
0

A great answer that answers this is HERE under a question marked as duplicate of the above and closed. I post here a screenshot:

enter image description here

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