2
votes

I have read the documentation for gdrive here, but I couldn't find a way to do what I want to do. I want to write a bash script to upload automatically a specific folder from my hard drive. The problem is that when I upload it several times, instead of replacing the old folder by the new one, it generates a new folder with the same name.

I could only find the following partial solutions to my problem:

  • Use update to replace files. The problem with this partial solution is that new files inside the folder could not get uploaded automatically, and I would have to change the bash script every time a new file is produced in the folder that I want to upload.
  • Erase the folder by its id from google drive and then upload the folder again. The problem here is that whenever I do this, the id of the uploaded folder chagnes, so I couldn't find a way to write a script to do the work.

I am looking for any method that solves my problem. But the precise questions that could help me are:

Is there a way to delete a folder from google drive (using gdrive) by its name instead of by its id?

Is there a way to get the id of a folder by its name? I guess not, since there can be several folders with the same name (but different ids) uploaded. Or am I missing something?

Is there a way to do a recursive update to renew all files that are already inside the folder uploaded on google drive and in addition upload those that are not yet uploaded?

In case it is relevant, I am using Linux Mint 18.1.

1

1 Answers

1
votes

Is there a way to delete a folder from google drive (using gdrive) by its name instead of by its id?

Nope. As your next question observes, there can be multiple such folders.

Is there a way to get the id of a folder by its name? I guess not, since there can be several folders with the same name (but different ids) uploaded. Or am I missing something?

You can get the ids (plural) of all folders with a given name.

gdrive list -q "name = 'My folder name' and mimeType='application/vnd.google-apps.folder' and trashed=false"

Is there a way to do a recursive update to renew all files that are already inside the folder uploaded on google drive and in addition upload those that are not yet uploaded?

Yes, but obviously not with a single command. You'll need to write a short script using gdrive list and parse (awk works well) the output.