1# credit to Stack Overflow user in the source link
2
3from pydrive.auth import GoogleAuth
4from pydrive.drive import GoogleDrive
5from google.colab import auth
6from oauth2client.client import GoogleCredentials
7
8auth.authenticate_user()
9gauth = GoogleAuth()
10gauth.credentials = GoogleCredentials.get_application_default()
11my_drive = GoogleDrive(gauth)
12
13# all files
14for a_file in my_drive.ListFile({'q': "trashed = true"}).GetList():
15 print(f'the file "{a_file['title']}", is about to get deleted permanently.')
16 a_file.Delete()
17
18# specific file
19for a_file in my_drive.ListFile({'q': "title = 'weights-improvement-01-10.5336.hdf5' and trashed=true"}).GetList():
20 print(f'the file "{a_file['title']}", is about to get deleted permanently.')
21 a_file.Delete()