Debdeep Bhattacharya

View My GitHub Profile

Google drive client (gdrive) for command line

17 Jun 2019

A git-like command line tool called drive has implemented all the features though auth2 secret key. Follow the instructions in its readme file, run

 	drive init ~/gdrive

to start the service. In the command line, it will give you a link to visit to get a secret key which you enter in the command line. After that pull, push etc covers everything, Look at the Readme in the github for all information.

Usage

After drive init, go to the directory you initiated drive and then

 	drive pull 'directory name'

pulls all the files, directories etc of ‘directory’ name.

Similar to git, to push files to drive, you can create subdirectory inside the local gdrive structure. For example,

 	cd ~/grive
	mkdir new-folder
	cd new-folder
	cp ~/newfile ./
	drive push

Be aware, if you do not have a copy of the remote files in the local location, drive push will delete the ones that are not present in the local path or in its children.

Issue: the authentication token expires occasionally, forcing you to follow some link, clicking on “Accept” and generate token, copy-paste it to the terminal window.

Either

 	drive trash 'file to be trashed'

Or, remember the name (with path) of the directory you want to delete. rm -r in local path. Then

  drive push 'path to the deleted file'

to delete it remotely.

The url command prints out the url of a file. It allows you to specify multiple paths relative to root or even by id

 $ drive url Photos/2015/07/Releases intros/flux