Problem
No button to delete everything on a shared drive. Deleting one-by-one is not a viable option, there is too many files.
Environment
- Google Drive web
- Google Script
Solution
- Open https://script.google.com.
- Click New project.
- Name the script project in the title.
- Delete the code "function myFunction() {}" and add the next script:
function myFunction() { var optionalArgs={'driveId':'THE TEAM DRIVE ID', 'includeItemsFromAllDrives':true, 'corpora': 'drive', 'supportsAllDrives': true, 'q':'trashed = true' } var trashed=Drive.Files.list(optionalArgs).items; for(var i=0;i<trashed.length;i++){ Drive.Files.remove(trashed[i].id, {'supportsAllDrives':true}) } }
- Replace THE TEAM DRIVE ID with the Shared Drive ID.
- Click Services + in the left navigation panel.
- Select Drive API and click ADD.
- Save Google Apps Script project using the button in the toolbar.
- Click Run.
- It will ask for your permissions in the first run, click Allow.
Cause
There is not an option to empty the trash folder for Shared Drives.