Bulk copy an entire Google Drive folder to another location in your Google Drive.
This script will recursively copy a source folder into a destination folder.
- Files are skipped if they match a certain pattern (see
config/config.yml
for the ignore list) - Files are only copied to the destination once, meaning you can delete them from the destination and then re-run this script without re-copying the file.
Google Developer Console
- Browse to the Google Developers Console
- Create a new project called "Google Drive Bulk Copy".
- On the Dashboard, click "Library" in the sidebar
- In the search box, type "Drive" and click "Google Drive API"
- Click "Enable"
- In the sidebar, click "Credentials".
- Click "Create Credentials", and select "OAuth Client ID".
- Under "Create Client ID", select "Other".
- For "Name", type "CLI".
- Close the dialog that pops up with the Client ID and secret. We'll download those in the next step.
- Find your Client in the list of Client ID's, and click the Download button next to it.
- Copy the
client_secret_1234-abcd.json
file that you download toconfig/client_secret.json
.
PHP
- You'll need at least PHP 5.4 with the php-sqlite package installed
- Lastly, you'll need to install the Composer dependencies:
composer install
- Find the full URL to your Source and Destination folders in Google Drive:
- Start the copy with:
php copy.php https://source-folder-url http://destination-folder-url