Nextcloud command-line client
AGPL-3.0 License
ow - Nextcloud command-line client
ow action target
ow (like, you're trying to say "owl" and almost succeed) is your handy local command-line pal for Nextcloud. ow enhances local editing, collaboration, and more by providing missing features or by providing a command-line interface for existing features.
Output is generally minimal on success. If an error occurs, messages are printed to standard error and a nonzero exit code is returned.
# Add all media in a folder to an album.
ow dir-album "Photos/2020/Camping trip"
# Get internal link for a file.
ow internal-link ~/Nextcloud/Readme.md
# Find and delete old calendar events.
ow delete-old-events 'calendar=personal,minimumAge=2y'
# Lock a file.
ow lock ~/Nextcloud/Readme.md
# Unlock a file.
ow unlock ~/Nextcloud/Readme.md
ow
scriptow
in your $PATH
and make it executable, e.g. ln -s ~/git/meonkeys/ow/ow ~/.local/bin
requests
library (via e.g. pip install requests
or apt install python3-requests
)xmllint
at /usr/bin/xmllint
(for debugging API responses)
apt install libxml2-utils
python3-argcomplete
for Bash programmable (Tab) completion
eval "$(register-python-argcomplete3 ow)"
in your ~/.bashrc
Create ~/.config/ow/ow.ini
and customize, following the example below:
[server]
# Must start with https
baseUrl = https://cloud.example.com
username = user
# If you use multi-factor auth, use an app password here.
password = redacted
[local]
# If you use the Nextcloud Desktop client, set this to indicate where files are sync'd.
# Required for lock, unlock, and internal-url.
# Not needed for dir-album nor delete-old-events.
syncFolder = /home/user/Nextcloud
List available actions.
ow --help
Add all media in a folder to an album.
ow dir-album "Photos/2020/Camping trip"
This works directly against the Nextcloud WebDAV API; the desktop client is not required.
This command expects that the provided path contains media compatible with the Photos and Memories apps (generally just photos and videos). Sub-folders and non-compatible file types are ignored.
The new album will be named by transforming the last path element. Some arbitary cleanup steps are performed. Examples:
Path | Album |
---|---|
Photos/2020/Camping trip/ | Camping trip |
Photos/2020-Camping trip | 2020-Camping trip |
Photos/2020-04-01 Camping trip | Camping trip |
Example Python script for converting a bunch of folders to albums at once:
import subprocess
folders = [
'Photos/2020/Camping trip',
'Photos/2021/sunny day'
]
for folder in folders:
subprocess.run(['./ow', 'dir-album', folder])
Given a local file path sync'd by the Nextcloud desktop client, return the "internal link" on the Nextcloud server.
ow internal-link ~/Nextcloud/test.md
# example output:
# https://cloud.example.com/f/229
Find and delete old calendar events given an event filter specification.
This will delete events older than 2 years on a calendar called "personal":
ow delete-old-events 'calendar=personal,minimumAge=2y'
Lock a file.
ow lock ~/Nextcloud/Readme.md
Locking indicates to other users your wish to avoid conflicts in shared files.
Unlock a file.
ow unlock ~/Nextcloud/Readme.md
Patches welcome. Ask before submitting anything larger than an obvious bugfix. Create a GitHub pull request. Add your name below.
ow is written in Python. It examines local files sync'd by the Nextcloud desktop client for some operations, and talks with the Nextcloud WebDAV API for others.
ow started with one command (get internal link for locally sync'd file).