Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import gdata.docs.data
- import gdata.docs.client
- client = gdata.docs.client.DocsClient(source = 'names-update-1')
- client.ssl = True
- client.http_client.debug = False
- client.ClientLogin('user.name@gmail.com', 'password', client.source)
- docs = client.GetEverything()
- types = {
- 'image/vnd.djvu': '.djvu',
- 'chemical/x-chemdraw': '.chm',
- 'spreadsheet': '.xls',
- 'pdf': '.pdf',
- 'document': '.doc',
- 'presentation': '.ppt'
- }
- for doc in docs:
- print "Processing %s" % doc.title.text
- ext = types[doc.get_document_type()]
- name = original_name = doc.title.text
- # append file suffix if not present
- if not name.endswith(ext):
- name += ext
- parts = name.split('.')
- parts.pop()
- name = ' '.join(parts) + ext
- if name != original_name:
- try:
- print "Updating with new name %s" % name
- doc.title.text = name
- client.Update(doc)
- except Exception as boom:
- print "Epic fail", boom
Add Comment
Please, Sign In to add comment