Cross-platform command line interface for OneDrive (Personal)
The provided shell.nix for the Nix package manager contains all development dependencies.
Use it with nix-shell or Direnv's use nix.
node2nix -l package-lock.jsonFrom source:
$ git clone https://github.com/lionello/onedrive-cli.git
$ cd onedrive-cli
$ npm install
$ bin/onedrive loginOr use npm:
npm install @lionello/onedrive-cliOr use nix-env:
nix-env -if https://github.com/lionello/onedrive-cli/archive/master.tar.gz -A packageusage: onedrive COMMAND [arguments]
This little utility supports the following commands:
cat- dumps the contents of a file to stdoutchmod- change sharing permissionscp- copies local file(s) to OneDrive or vice-versadf- shows OneDrive storage usage statsfind- find file(s) or folder(s) by name, optionally separated byNULhelp- shows list of supported commandsln- create a link to the remote itemlogin- request/store an OAuth access tokenls- list the contents of a foldermkdir- create a remote foldermv- move a local file to OneDrive or vice-versarm- delete a file from OneDrive (not implemented)sendmail- send an invitation email for editing to recipientsstat- dump all information for particular file(s)wget- copy a remote URL to OneDrive (server side)
onedrive ls Public
onedrive cat Documents/passwords | grep boa
onedrive wget http://mega.com/somehugepublicfile Documents/somehugepublicfile
find * -type f -print0 | xargs -0 -n1 -I{} onedrive cp "./{}" "Shared Favorites/{}"
onedrive find 'Pictures/Camera Roll' -regex 2015 -type f -print0 | xargs -0 onedrive mv -t :/Pictures/2015/
The onedrive utility needs an access token in order to read/write to your OneDrive storage.
Use theonedrive login command to get the address of the Microsoft login page. After login,
this page will redirect to the file oauthcallbackhandler.html (https://github.com/lionello/onedrive-cli/blob/master/docs/oauthcallbackhandler.html)
and extract the access_token from the URL parameters. Copy-paste this token into the command line.
This will save the token in a file called ~/.onedrive-cli-token. These tokens have a validity of 1 hour.
Currently, a copy will fail if a file with the same it already exists. Change the name of the target, or use other means to delete/rename the existing file in your OneDrive.
You cannot copy folders. Specify a source file instead, or use wildcards.
The target file name cannot be determined from the source path. Specify a target file name.
The cp command supports both local->remote as well as remote->local copy.
To make it clear which path is remote and which is local, either use ./ as a prefix for
the local path, or use :/ as a prefix for the remote path. Either one will suffice.
The chmod command currently only supports -w or -rw. The former tried to downgrade write
shares to read-only, whereas the latter removes all shares for the given item(s). Octal modes are accepted (for example 644, 0700) as well as og-rw or g-w.
- Implement
rm - Support gzip/deflate encoding for downloads
- Uploads larger than 100MiB are not yet supported (needs range API)
- Support OneDrive for Business
- Ability to get the link for a file
- Skip upload/download if the SHA1 matches
- Adding write permissions (+w) to existing share links
- Register with NPM (@lionello/onedrive-cli)
- Fixed OAuth redirect on Safari (https://bugs.webkit.org/show_bug.cgi?id=24175)
- Use XDG path spec for token file (https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
- Using
async/await