Nextcloudには、ファイルやフォルダーにタグを付与する機能があります。
Nextcloudのタグは、通常はNextcloudのGUI画面もしくは”Files automated tagging”アプリによる自動タグ付け機能で付与します。
Nextcloudのタグ付け機能や自動タグ付け機能については、以下の過去ブログ記事をご参照ください。
■Nextcloud のタグ機能
https://nextcloud.stylez.co.jp/blog/nextcloud-tags.html
■Nextcloud のオートタギング機能
https://nextcloud.stylez.co.jp/blog/nextcloud-autotagging.html
コマンドライン(CLI)によるタグの付与は、長らく機能として実装されていませんでした。
これまで、コマンドレベルでファイルやフォルダーにタグを付与するには、データベース直接操作を含む複雑な実装が必要となり、かなり大変でした。
しかし、最近、ファイルやフォルダにタグを付与できるNextcloudのoccコマンドが追加されました。
これにより、CLIでも簡単にタグの付与ができるようになりました。
■"occ tag:files:add" コマンド: ファイルやフォルダにタグを追加
$ sudo -u www-data php /var/www/html/nextcloud/occ tag:files:add -h
Description:
Add a system-tag to a file or folder
Usage:
tag:files:add <target> <tags> <access>
Arguments:
target file id or path
tags Name of the tag(s) to add, comma separated
access access level of the tag (public, restricted or invisible)
Options:
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
--no-warnings Skip global warnings, show command output only
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
●設定属性
- target: タグを設定するファイルまたはフォルダーパス。"/【アカウント名】/files/【ファイルまたはフォルダーパス】"で指定します
- tags: 付与するタグ名。日本語等のマルチバイト文字列も指定可能です
- access: タグのアクセスレベルを指定します
- "public": 公開
- "restricted": 制限付き
- "invisible": 不可視
●補足事項
- 指定したタグがNextcloudに登録されていない場合は、タグの作成も一緒に行われます
- 指定したタグがNextcloudに登録済みの場合でも
access属性の指定は必要です- この時、指定したタグ名とアクセスレベルが登録済みタグのものと一致していないと実行エラーとなります
