简体   繁体   中英

How to remove a resource (Google Docs document) from the root collection (folder)

I am using the python gdata library to copy and move a google Docs file in a specific folder. I am using the MoveResource method from DocsClient, the file appears in the desired folder, but also stays in the root folder.

I cannot figure out how to remove it from the root folder?!

import gdata.docs.service
import gdata.docs.client
import gdata.docs.data

doc_service = gdata.docs.client.DocsClient() 
doc_service.ClientLogin('myId', 'myPassword', 'myAppName')

# this is my source document
doc = doc_service.GetResourceById('ABC123')

# extracting the folder of my source document to move the copy in the same folder
for parent in doc.InCollections(): 
    if parent.title == 'myFilter':
        destination_folder_id = parent.href.split('%3A')[1]
        destination_folder = doc_service.GetResourceById(destination_folder_id)

# making a copy of my source
newdoc = doc_service.CopyResource(doc, 'Test Python')

# moving my copy to the same folder as my source
# but the copy also stays in the root folder!
moveddoc = doc_service.MoveResource( newdoc, destination_folder )

您可以使用以下代码从根集合中删除Google Docs文件:

doc_service.Delete('https://docs.google.com/feeds/default/private/full/folder%3Aroot/contents/' + doc.resource_id.text, force=True)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM