skip to content
Site header image Mimansa Jaiswal

Copy folders from one gdrive to another


You just graduated and your university is downgrading you to the 15GB plan on google drive?

And you have 200GB on there?

And you do not want to download all of it using google takeout?

You can use this method.

  1. Share the folder to your personal account
  2. Wait at least 2 days for permissions to propogate
  3. Add shared folder as shortcut in My Drive
  4. Open colab, paste the following code, modify the folder names and run
  5. Give permissions to access drive
  6. Make sure you note down which files are not copied — because google suite specific files are not (slides, sheets, docs etc) — but they are usually tiny anyway.
from google.colab import drive
import os

print('Mounting Google Drive...')
drive.mount('/gdrive')

src_path = '/gdrive/MyDrive/UMich' #@param {type: 'string'}
assert os.path.exists(src_path), f"Source '{src_path}' doesn't exist!"

target_path = '/gdrive/MyDrive/Copied From UMich' #@param {type: 'string'}
os.makedirs(target_path, exist_ok=True)
assert os.path.exists(target_path), f"Target '{target_path}' doesn't exist!"

target_path = os.path.join(target_path, os.path.basename(src_path))
print(f'Copying from "{src_path}" to "{target_path}"...')
os.makedirs(target_path, exist_ok=True)
!cp -rn "$src_path"/* "$target_path"  # also work when source is a shortcut
Code to copy from a shared folder to personal drive using Google colab