Google Drive API - Rename duplicate files / folders

You create an empty document. You forgot to name the file and just close the window after typing something. The file will stay in your Google Drive with the name "Untitle Docutment". You repeat that action some other times. You will end up having so many duplicate files (or folders) in your Google Drive with the same name.

...

Someday you will (I will) need to re-organize all the documents and folders in your Drive account. The first thing to do is to rename all the duplicate files or folders by modified date. The newest file will have the name (e.g. "My document"), and the older files will have number after the name ("My document (1)", "My document (2)",...)

The following snippet I wrote to do the renaming task and make the world alot easier:from dateutil import parserdef rename_file(service, file_id, new_title): """Rename a file.