Copy the folder on Google drive

Tram Ho

Surely in us, many times there is a need to copy folders from one place to another on google drive. Unlike copying on PC, google drive only allows copying files.

I also do not understand why google does not allow directory copy

I searched on the Internet, there are many ways, either you can use that power to download the folder and upload it again, or use a 3rd party extension. I guess most of you use the way 3rd party extension is both fast and easy. But for folders that are project documents, the use of any 3rd party software should be avoided for security reasons .

So today, I would like to introduce another way, it may take some time to install initially, but then each time you want to copy the folder, it only takes 2, 3 light actions.


  1. Setting
  2. Use

1. Install

We will use Google Apps Scripts. For those of you who are programming, it may be easier to understand, you do not have to worry about other industries because simply copying your code is ok.

Google Apps Script – is a Javascript-based programming language with editors and translators located on Google’s servers. With this tool, you can program to manipulate, intervene directly with Google services.

You go to , because it is a google service, you should log in with your google account. After logging in, click the New Project button

Will open to the new screen, copy the code I have below the image and add it as shown below:

After adding the code, remember Ctrl S to save, and add a project name of your choice.

There will be many options for you to choose in copying, but here I introduce the two options I use most:

  • Copy to your own drive.
  • Copy to another directory that you have the right to modify.

2. Use

1. Copy to your own drive In the above code, there are 2 important parts that

  • sourceFolderID is the ID of the folder you want to copy
  • destFolderID is the ID of the destination folder that you want to copy to, you temporarily ignore.
  • namefolder is the name of the folder that you want to give the copied folder after it is saved to your My folder.

First, go to the folder you want to copy to get the ID. In this example, I assume I want to copy the album1 folder to My drive.

Replace the <sourceFolderID>

After that the targetFolder part will fill in the name you like for example

At this point, you will need to change a bit in the above code: remove comment – 2 // marks from line 1 and add these 2 marks in the 2nd as below.

Once done, press Ctrl S to save the code. The final step is to press Start as shown below and wait.

When the message below turns off is considered to have finished running.

You try to check My Drive offline

2. Copy to another directory that you have the right to modify

I would like to introduce the second option. Back to the source and target code

At this time, you still need to copy the folder to get the ID and replace the <sourceFolderID>

Then go to the destination folder – the folder you want to copy to also get the ID and replace the destFolderID part. For example, I want to copy album1 folder to videos folder

At this point, the code copy will be as follows.

Similar to the above, save and start the code, wait for the copy and check the goods.

Note: In option 2, will copy the contents of the album1 folder. For example, in album1, you have 2 image files, it will only copy 2 image files only. And album1 folder will not be moved. Therefore, create the folder containing the contents of the album1 folder first, get that ID is sourceID and ID of album1 is targetID.

From next time onwards, all you need to do is change the sourceID , targetID and 2 lines of code related to the copy of the 2 options.

Thanks for reading. If there is anything difficult to understand, please comment below.

Share the news now

Source : Viblo