Google Drive – How Many Spreadsheets Are Stored

google sheetsgoogle-drive

A Google survey asked me:

About how many spreadsheets are stored in your Google Drive?

I ended up guessing, because I couldn't find a way to find the real number. In Google Drive interface, there is an option to search for spreadsheets (type:spreadsheet), but the search returns only the 20 most recently active documents. There is no pagination of search result that I could see. So, how can I:

  1. Find how many Google Spreadsheets I have?
  2. (less important) get the list of these spreadsheets?

The Sheets interface theoretically shows all of them, but in the form of infinite scroll, and without a counter.

Best Answer

The following script will give you the count in the Logger log. 776 in my case. Which was interesting to know.

function findOut() {
  var docs = DriveApp.getFilesByType(MimeType.GOOGLE_SHEETS);
  var i = 0;
  while (docs.hasNext()) {
  var doc = docs.next();
  i++;
 }
  Logger.log(i);
}

This script will list all the names. You could write the data to a spreadsheet as well if you're looking for an index of sorts.

function findOut() {
  var docs = DriveApp.getFilesByType(MimeType.GOOGLE_SHEETS);
  var i = 0;
  while (docs.hasNext()) {
  var doc = docs.next();
  Logger.log(doc.getName())
 }

}