2

Google Drive does not give you a break down of each folder size individually, so when getting close to the limit of storage, it would be nice to know which folders are taking up the most space.

How can I use rclone (rclone.org) to get the size of a folder and how much space it is using, on Google Drive?

jsherk
  • 6,128
  • 8
  • 51
  • 83

2 Answers2

3

To get the total space used by your entire Google Drive use this:

rclone size "myGoogleDrive:/"

To get the total size (space used) of one particular folder, use this:

rclone size "myGoogleDrive:myFolderName/"

Thanks to the following post for helping figure this out: https://www.guyrutenberg.com/2017/08/23/calculate-google-drive-folder-size-using-rclone/

WINDOWS PHP SCRIPT TO FIND ALL TOP LEVEL FOLDER SIZES:

Note that the following script is written in PHP on Windows. You need to make sure shell_exec() command is not disabled in php.ini. You can run the script from command line or powershell using php filename.php

It assumes you have rclone installed and included in your windows environment path.

It will first retreive a list of all top level folders from your Google Drive, and then breaks the returned string into an array.

It will then loop thru the array and pull each directory name out and get its size.

<?php
    echo "\r\nGOOGLE DRIVE - Total Storage Space Used (by top level directories)\r\n\r\n";
    echo "Running RCLONE LSD...\r\n\r\n";
    $dir_list_string = shell_exec('rclone lsd myGoogleDrive:'); // Get top level directory listing
    echo "FOUND THESE...\r\n";
    echo $dir_list_string."\r\n\r\n";
    echo "Running RCLONE SIZE...\r\n\r\n";
    $dir_list = explode("-1 ", $dir_list_string); // Split the returned string into an array
    $count_list = count($dir_list); // How many items in the array?
    for ($i = 2; $i < $count_list; $i=$i+2) {
        $dir_list[$i] = trim($dir_list[$i]); // Get rid of white space around name
        echo "Checking size of: ".$dir_list[$i]."\r\n";
        $size_string = shell_exec('rclone size "myGoogleDrive:'.$dir_list[$i].'/" '); // Get size of each directory
        echo $size_string."\r\n";
    }
    $size_all = shell_exec('rclone size "myGoogleDrive:/" ');
    echo "TOTAL SPACE USED FOR ENTIRE GOOGLE DRIVE:\r\n";
    echo $size_all."\r\n";
    echo "DONE\r\n\r\n";
?>
jsherk
  • 6,128
  • 8
  • 51
  • 83
1

I don't know if this can really be considered as an improvement to the previous answer, or simply another way to do this.

Anyways, this method also uses rclone and works more or less better, because you will use the GUI to view the size of the folders, but GUIs are usually slower than a pure command line interface. Nevertheless, you can view all sub-folders and their size.

  1. Download Rclone and set it up to use Google Drive.

  2. Once downloaded and configured for Google Drive, type :

rclone mount GDrive: d:

  1. Use Windows Explorer or any folder size viewer (WinDirSat, TreeSize), to view all folders details and folder sizes.

I will explain each point in detail.

To download RClone, this is pretty straightforward. Go here : https://rclone.org/downloads/

To setup Rclone, this is also very straightforward and, this is not often the case for other softwares, but the documentation from the developers is very good : https://rclone.org/drive/

To mount a local drive, RClone can let you mount a 'cloud folder' as a local drive on Windows, and the code of RClone seems to be very well tested, because this feature is very stable. But to do this, you must download and install WinFUSE here : https://github.com/billziss-gh/winfuse

You then type rclone mount GDrive: d: to mount your cloud storage called GDrive: as the drive letter D: ("GDrive:" and "D:" name CAN change according to the configuration you made earlier and the drives on your computer, so please change it, according to your set up)

Finally, you can view the folders and analyse them with an adequate software, as any other files on your system.