0
votes

Helo

Im newbies on google script, I have a Google Drive folder list in Google Sheet, how do I delete folders on Google Drive based on the data on the Google sheet?

1
What information do you have about folders in the sheet?Amit Agarwal
Please edit to add meaningful code and a problem description here. Posting a Minimal, Complete, Verifiable Example that demonstrates your problem would help you get better answers. Thanks!Rafa Guillermo
I Have Googledrive ID, Folder ID, File Name, Folder NameDinda Lesmana

1 Answers

0
votes

If you have the ID you can use the getFolderByID() method followed by the setTrashed() one.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet(); //or getSheetByName() if necessary
var folderToDelete = sheet.getRange(<range of your folder IDs list>);
var folderIDs = folderToDelete.getValues();

folderIDs.forEach(function(id){
  DriveApp.getFolderByID(id).setTrashed(true);
});