prasmussen / gdrive

Google Drive CLI Client
MIT License
8.99k stars 1.19k forks source link

Upload multiple files into an existing directory #354

Open unim21 opened 6 years ago

unim21 commented 6 years ago

Greetings!

I am unable to pass a wildcard into the path of the file with the following command:

gdrive upload --parent <folderId> /home/ubuntu/folder/*files_I_want.csv

This returns an "no argument passed" error from the gdrive client (when I specify the file directly without using a wildcard I do not get this error and the upload succeeds).

I simply want to upload all files of a certain type to an existing directory. I have explored attempting to upload the entire folder itself, but this is problematic as it creates a new folder within Google Drive that doesn't have the proper permissions (which I would have to add back manually every time my script does an upload).

Is there no other way to upload all contents of a local directory into an existing Google Drive folder without the client automatically creating a new folder?

elliott-beach commented 6 years ago

@unim21 Could you do

for f in *files_I_want.csv; do gdrive upload --parent <folderId> $f; done

gdrive apparently doesn't support uploading multiple files.

trcyprkr commented 6 years ago

So is there a fix possibly forthcoming to this issue? Seems this should be a fundamental task. Also, i want to cd into a particular director and 'list' files in that directory. Cant seem to make it happen.

elliott-beach commented 6 years ago

Does the bash for loop not work? That should allow uploading multiple files. Also, this project isn’t maintained, so no fixes :P

There are also some other projects that do the same thing: I’d research what rclone provides.

unim21 commented 6 years ago

The for loop does work for this particular scenario, however the other problem I am running into is the uploading of duplicate files.

For instance, I need one file with a static name, e.g. "staticFile.csv", and it's backups for the last 7 days uploaded into a directory. Since my script runs every 15 minutes, "staticFile.csv" and it's backups get duplicated on the upload. I haven't found a way to tell gdrive to ignore duplicates, so for the time being I'm using another cmd-line app located here https://github.com/odeke-em/drive

It's a bit more difficult to setup and requires Go dependencies to be installed, but it's much more robust and offers a broader range of functionality. Regardless, it took me forever to setup on Ubuntu 14.04 and actually get it working properly.

Gdrive would be a much better alternative for the current project I am working on if there was a workaround for the issue with duplicate files getting uploaded into drive.