Drive Management: A Script to List File Sizes and Names

The following script will iterate through the files in the specified folder and log the names and sizes of these files. You customise this to include additional details you may need.

function listFilesAndSizes() {
  var folderId = 'YOUR_FOLDER_ID_HERE'; // Replace with your folder ID
  var folder = DriveApp.getFolderById(folderId);
  var files = folder.getFiles();

  while (files.hasNext()) {
    var file =;
    var fileName = file.getName();
    var fileSize = file.getSize(); // Get the size of the file

    Logger.log('File Name: ' + fileName);
    Logger.log('File Size: ' + fileSize + ' bytes');

Steps to Use the Script

  1. Replace 'YOUR_FOLDER_ID_HERE': Input the ID of the Google Drive folder you want to inspect.
  2. Save and Run the Script: Save your script and run the function listFilesAndSizes.
  3. Grant Permissions: Google Apps Script will ask for permission to access your Google Drive. You need to grant these permissions.
  4. View the Output: Once the script has run, view the logs by clicking on View > Logs in the script editor. Here you will see a list of files along with their sizes in bytes.

The script will output:

  • The name of each file in the specified folder.
  • The size of each file in bytes.

This script is a basic version and can be customized further based on your requirements. For instance, you could add functionality to convert the file size into more readable formats (like KB, MB, etc.), or extend the script to include additional file details.

This script is an effective way to get a quick overview of the files in a specific Google Drive folder, especially when dealing with large numbers of files or managing storage space.

If you are looking for a more Google Workspace Addon to help you audit and scan your Google Drive files, Here is a Drive Permissions Scanner – by