I am trying to upload documents to my Microsoft OneDrive
account using python-onedrive
. The command I am using is this:
onedrive-cli put Long\ Filename\ 1.jpg
onedrive-cli put Long\ Filename\ 2.jpg
The problem is that there are a lot of these files, and I want to upload all of them (There is no option to upload an entire directory). I have using the asterisk but that doesn't work either:
user@office-debian:~/Desktop/docs$ onedrive-cli put *
usage: onedrive-cli [-h] [-c path] [-p] [-i] [-e enc] [--debug]
{auth,quota,recent,info,info_set,link,ls,mkdir,get,put,cp,mv,rm,comments,comment_add,comment_delete,tree}
...
onedrive-cli: error: unrecognized arguments: Long Filename 1.jpg Long Filename 2.jpg
I presume this is because the program expects the spaces to be escaped, but the asterisk doesn't expand them that way. I have tried "piping" the arguments to no avail:
user@office-debian:~/Desktop/docs$ ls | onedrive-cli put
usage: onedrive-cli put [-h] [-n] file [folder]
onedrive-cli put: error: too few arguments
Evidently onedrive-cli
doesn't recognise STDIN
. Are there any other simple options left? I realise I could probably write a script but I was really hoping to avoid that!
The following seems to work, but it's not really what I had in mind:
for files in * ; do
onedrive-cli put "$files"
done
Best Answer
If the following doesn't work...
Then it's probably because you need a
put
for every argument in which case this might:But if that doesn't work then your
for
loop probably is the best shell solution because your python script will only support one upload per invocation.The best way to do it though is to edit the python script to meet your needs.