Featured Post

Step Wise Project Planning

Planning is the most difficult process in project management. The framework described is called the Stepwise method to help to distinguis...

Google Apps Script that you can use to get the count of all files in a Google Drive folder and write it to a Google Sheets spreadsheet



Google Apps Script that you can use to get the count of all files in a Google Drive folder and write it to a Google Sheets spreadsheet


function getFileCount() {

  // Get the folder ID of the folder you want to count files from

  var folderId = "your_folder_id";

  

  // Get the folder using the ID

  var folder = DriveApp.getFolderById(folderId);

  

  // Get all the files in the folder

  var files = folder.getFiles();

  

  // Get the count of the files in the folder

  var fileCount = 0;

  while (files.hasNext()) {

    files.next();

    fileCount++;

  }

  

  // Get the active sheet in the spreadsheet

  var sheet = SpreadsheetApp.getActiveSheet();

  

  // Write the header row in the sheet

  sheet.appendRow(["File Count"]);

  

  // Write the file count in the sheet

  sheet.appendRow([fileCount]);

}


You can run the script by clicking the "Run" button in the Google Apps Script editor. Make sure to replace "your_folder_id" with the actual ID of the folder you want to count files from.
Previous
Next Post »