I am developing a python script that will upload files to a specific folder on my disk, as I already noticed, the api drive provides an excellent implementation for this, but I ran into one problem: how to delete several files at once?
I tried to grab the files that I want from the disk and organize their identifier, but there was no luck ... (fragment below)
dir_id = "my folder Id"
file_id = "avoid deleting this file"
dFiles = []
query = ""
children = service.files().list(q="'"+dir_id+"' in parents").execute()
for i in children["items"]:
print "appending "+i["title"]
if i["id"] != file_id:
dFiles.append(i["id"])
query +=i["id"]+", "
query = query[:-2]
service.files().delete(fileId=query).execute()
Is it possible to delete selected files (I donβt understand why this would be impossible, because this is the main operation)?
Thanks in advance!
source
share