was insufficient.
As shown in the image above, I would like to use GAS to reflect the number of files in Google Drive corresponding to each item in the spreadsheet in the Number of Cases column. How can I do this?As shown in the image below, the folders in the Google drive are divided into items, and I would like to reflect the number of files in this folder for each item.
Please help me.
Loop all files in your Google drive with DriveApp.getFiles() and count each time to get the number of files.
"Also, it seems that ""shared items"" and ""recently used items"" are counted."
Also, if you have a large number of files, it may not be finished within the Google AppsScript time limit, so you may need to think about it separately.
function myFunction(){
var count = 0;
var files = DriveApp.getFiles();
while(files.hasNext()){
count++;
var file=files.next();
}
SpreadsheetApp.getActiveSheet().getRange("A1").setValue(count);
}
© 2024 OneMinuteCode. All rights reserved.