How to move files and folders using google drive API?

NitinJ picture NitinJ · Oct 8, 2012 · Viewed 19.5k times · Source

I am trying to use Google drive API to carry out simple tasks like

  1. Moving files across folders.
  2. List item

Moving folders.

As far as I could find Google drive API does not provide a way to move files across folders.

With /parent and /children API parent folder of a file can be specified but it does not work for a folder. Moreover the parent attribute associated with a file does not move it under that folder. It just associates a parent attribute with the file(which is not at all useful for my case)

Answer

intotecho picture intotecho · Jun 17, 2016

Drive API V3 has this:

Moving files between folders

To add or remove parents for an exiting file, use the addParents and > removeParents query parameters on the files.update method.

Both parameters may be used to move a file from one folder to another: https://developers.google.com/drive/v3/web/folder#inserting_a_file_in_a_folder