Automatically Empty Google Drive Trash

Want to empty your Google Drive Trash automatically?  I finally have the solution for you.

  1. Make sure you use GOOGLE CHROME web browser for best results.
  2. Open Chrome and go to www.google.com
  3. Make sure you are signed into your Google account.  If not, sign in.
  4. You should OBVIOUSLY have Google Drive account up and running since that’s why you’re here, right?
  5. Go here https://script.google.com/home
  6. Click NEW PROJECT.
  7. Clear out the default code that appears in the next window.
  8. Paste in this code (exactly)
    function createTimeDrivenTriggers() {
      ScriptApp.newTrigger('emptyThrash')
          .timeBased()
          .everyHours(1)
          .create();
    }
    function emptyThrash()
    {
    Drive.Files.emptyTrash();
    }
    
  9. Click the Save Icon
  10. Enter a name such as “Automatically Empty Google Drive Trash”
  11. Click the “Resources -> Advanced Google Services” menu within the Code editor
  12.  Scroll down and turn “Drive API” to “ON”
  13. You should see a message “These services must also be enabled in the Google Cloud Platform API Dashboard”.  Click that link.
  14. NOTE:  If you DO NOT see the message above, click this direct link
  15. Click “ENABLE APIS AND SERVICES”
  16. Locate “Google Drive API” and click it.
  17. Click Enable
  18. Go back to your browser window with the “Advanced Google Services” window still open.
  19. Click OK
  20. Click the “Run” icon within the project editor
  21. You should see “Authorization Required”.  Click Review Permissions
  22. Choose your google account (this links up the script with the proper account).
  23. You will see “This app isn’t verified”.  Click Advanced. Click Go to XXXX Project (unsafe).
  24. Click ALLOW
  25. Save your project again.
  26. Go to “Run->Run Function->createTimeDrivenTriggers”
  27. Hit the “Timer” icon.
  28. You should see your project listed under “Triggers”
  29. Your job is now scheduled to run every 1 hour and empty your trash!

 

This process was crafted by deciphering the following two pages:

https://stackoverflow.com/questions/32749289/automatically-delete-file-from-google-drive-trash

https://stackoverflow.com/questions/25749906/permanently-delete-file-from-google-drive/32749203

5 comments

  • ANoob1

    Thanks. I have been looking for this function for a year now.

  • Fito

    This was just what I needed to fully automate my sync process from NAS to gDrive.
    I can’t believe Google has no similar option to schedule this purge, or even to disable the trash bin directly.

    Many thanks!

  • Vladimir Gladkov

    Don’t work for me ((
    at # 19 I see:
    Sign in with Google temporarily disabled for this app
    This app has not been verified yet by Google in order to use Google Sign In.

    and no “Advanced” button…

  • Very Useful i really enjoyed your sharing

  • Jothish

    Thanks for Sharing

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.