A python package for cloning google drive folders, including all subdirectories and files
To install from the pypi release
pip install googledrive_cloner
To install locally
git clone https://github.com/NickHilton/googledrivecloner.git
In order for this package to work, any GDrive account you use must be set up with the correct permissions. More detail is given in Google's documentation
The following steps should get you set up correctly
- Create a Google Project - here
- Enable the Google Drive API on your project - here
- Create a service account for authorization as described in the documentation
- Save the client-secret created during the previous step to your environment and set the environment variable
CLIENT_SECRET_PATH
to point to the file - Enable sharing for the folder you wish to copy, and share the folder with the email from the created service account
To clone a directory you need to get both the gdrive id of the folder to be copied and the destination folder. You can discover these ids by looking at the url
https://drive.google.com/drive/u/0/folders/{FOLDER_ID}
The cloner can be used in the following way:
from googledrive_cloner.google_connections import GoogleDriveCloner
googledrivecloner = GoogleDriveCloner()
folder_id_to_copy = 'XXXXXXXX'
destination_folder_id = 'YYYYYYYYY'
new_folder_name = 'lemons' # Or something else!
googledrivecloner.run(
base_folder_id=folder_id_to_copy,
destination_parent_folder_id=destination_folder_id,
new_name=new_folder_name
)
All contributions are welcome, feel free to ask a question or propose a change via a Pull Request
In the root/src directory
python -m unittest discover