Google Drive Migrator is a Python script that recursively copies the contents of a Google Drive folder into another folder on Google Drive using the Google Drive SDK.
Note: Before continuing you should consider whether Google Takeout meets your needs.
The project uses Python 2.7 and pip
.
-
Grab the code
git clone git@github.com:socialsquare/google-drive-migrator.git
-
Install requirements
pip install -r requirements.txt
-
Get a Client ID and Secret Key
-
Create a project
-
Go to APIs & auth -> APIs and enable Drive API
-
Go to APIs & auth -> Credentials and then Create new Client ID and create a Web application, with a callback URI
http://localhost:8080/
.You should now see a Client ID and a Secret Key.
Notice that both Redirect URIs and JavaScript origins are set to
http://localhost:8080/
, if not, edit the setting and reset the secret. -
Click Download JSON and save the JSON file as
client_secrets.json
in the google-drive-migrator-folder.
Run
python copy_folder.py GDRIVE_FOLDER_ID_FROM GDRIVE_FOLDER_ID_TO
, where GDRIVE_FOLDER_ID_FROM
and GDRIVE_FOLDER_ID_TO
are Google Drive
folder ids of the folder to be copied from and the folder to be copied to
respectively e.g.
python copy_folder.py 'AaaadadOIDSAD22323' 'BDK-LFJfkajsadJAd231j'
the Google Drive SDK will automatically open your webbrowser where you have to
login to your Google account and authenticate the app you created.
The authentication is saved in saved_credentials.json
so that you don't have
to login on subsequent uses.
When you have authenticated in the browser (it shows a boring page with the text "the request has been authorized"), the script will start copying the folder.
Best wishes! Malthe from Socialsquare