Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Google Drive SDK how do you copy a folder?

Very simple question. How can I copy a folder with the Google Drive API?

It looks like the file/copy API endpoint doesn't work with folders (though this limitation is not clearly indicated in the documentation).

Of course I could add a second parent to the file, but obviously that's not a solution as most of the time a folder copy is done to do something with it without modifying the original.

So how can I do that? Any idea?

like image 796
Martin Avatar asked Sep 26 '12 15:09

Martin


People also ask

Is there a way to copy a folder in Google Drive?

If you have the Google Drive app installed on your computer, you can copy a folder in Google Drive the same way you'd copy any other folder of files. Right-click on the folder, click Copy, then go wherever you want to copy the folder, right-click again, and click Paste.

How do I make a folder in Google Drive API?

To create a file in a folder, use the files. create method and specify the folder ID in the parents property of the file. The following code snippet shows how to create a file in a specific folder using a client library: Note: If you're using the older Drive API v2, use the files.


1 Answers

'copy' wouldn't make much sense on a folder. The purpose of copy is to create a second file with the same media content as the first. Since a folder has no media content, 'copy' doesn't really apply.

To answer the question, we need to understand your use case a little. Take a *nix paradigm, "cp -R folder1 folder2" is recursively duplicating all of the files. If that is your use case, you'll need to manually recurse down the tree. If you want the same files to appear in two places, (ie. "ln -s folder1 folder2") then that is done by adding a second parent.

like image 97
pinoyyid Avatar answered Sep 21 '22 02:09

pinoyyid