0

I made a google scripts function to clear my trashed files. I tried running it, and it did nothing. No logs either.

function clearTrashed() {
  var files2 = DriveApp.getFiles();
  while (files2.hasNext()) {
    var currentFile2 = files2.next();
    if (currentFile2.isTrashed()) {
      Drive.Files.remove(currentFile2.getId());
      Logger.log("Deleted file: " + currentFile2.getName());
    }
  }
}

I also have the Drive Api enabled in my google developers console and in advanced google services. It doesn't see any trashed files, because otherwise it would log them. Would add the tag google-script but dont have enough rep for it

HeyHeyJC
  • 2,627
  • 1
  • 18
  • 27
user233009
  • 296
  • 2
  • 11

1 Answers1

0

You can use Files: emptyTrash to permanently delete all of the user's trashed file by sending HTTP request:

DELETE https://www.googleapis.com/drive/v3/files/trash

To use this, you need to enable the Drive API service and please note that this request requires authorization with the following scope:

https://www.googleapis.com/auth/drive

This SO post - Permanently delete file from google drive might also help.

Community
  • 1
  • 1
Teyam
  • 7,686
  • 3
  • 15
  • 22