2022-10-03 08:19:35 -04:00
---
title : dirnotes-cli
section : 1
header : User Manual
footer : dirnotes-cli 1.0
date : Sept 26, 2022
---
# NAME
dirnotes-cli - view and manage Dirnotes file annotations
# SYNOPSIS
<!--- the indent below is using unicode hard space u00a0, and space at EOL --->
**dirnotes-cli** [-h] [--help] [-V] [--version]
List:
**dirnotes-cli** [-v] [-j] [-l] [-d|-x]
**dirnotes-cli** [-v] [-j] [-n] [-d|-x] [filename]...
**dirnotes-cli** [-v] [-j] -H [filename]...
Create:
**dirnotes-cli** -c "comment" filename...
**dirnotes-cli** -a "comment" filename...
**dirnotes-cli** -e filename...
FileCopy:
2022-11-01 17:54:22 -04:00
**dirnotes-cli** -C [-y] src-file... <dest-file | dest-dir>
**dirnotes-cli** -M [-y] src-file... <dest-file | dest-dir>
2022-10-03 08:19:35 -04:00
Cleanup:
**dirnotes-cli** -z [filename]...
**dirnotes-cli** -Z
# DESCRIPTION
The **dirnotes** family of apps allows you to add a descriptive comment to
a file. The descriptions are stored in two places:
* in the xattr properties of the file
* in a database located in the user's home directory
2022-11-01 17:54:22 -04:00
The **dirnotes-cli** is designed for use on the command line, or in
scripting.
2022-10-03 08:19:35 -04:00
The *list* commands will display the comment from the database or xattr (as
2022-11-01 17:54:22 -04:00
determined by the config file or as specified with ** -d**/**-x** options).
If the database and xattr comments differ, the
comment will be terminated by a '\*' character.
The ** -H** option displays the history of comments from the database.
2022-10-03 08:19:35 -04:00
2022-11-01 17:54:22 -04:00
The output of the *list* commands can be in .json format (**-j**) ,
and can optionally display the comment creator and the comment date (**-v**)
2022-10-03 08:19:35 -04:00
2022-11-01 17:54:22 -04:00
The *create* commands will attempt to store the file comments in _both_
the xattr of the file, and in the database.
If either of these fail, they fail silently. Use the ** -c** to create a comment,
use ** -a** to append to an existing comment, and ** -e** to erase a comment.
2022-10-03 08:19:35 -04:00
2022-11-01 17:54:22 -04:00
The *filecopy* commands will copy/move the file to a destination, and
preserve the file comments. [See notes below about LIMITATIONS]
2022-10-03 08:19:35 -04:00
The *cleanup* commands can clean up the history of comments in the database.
# LIMITATIONS
2022-11-01 17:54:22 -04:00
The file comments are located in two locations: a database, and in the xattr
properties of the file. Each of these storage locations has its own benefits
and limitations:
2022-10-03 08:19:35 -04:00
## xattr
2022-11-01 17:54:22 -04:00
Because _xattr_ comments are bound to the filesystem, other command line tools
may be used to manage them. Comments stored in the _xattr_ properties can be
copied/moved with the file, if you
2022-10-03 08:19:35 -04:00
use the correct options for _cp_ . The _mv_ utility automatically preserves _xattr_ .
Other programs can also be coerced into perserving _xattr_ properties:
* rsync
* tar
* mksquashfs
2022-11-01 17:54:22 -04:00
Not all file systems support _xattr_ properties (vfat/exfat does not).
2022-10-03 08:19:35 -04:00
2022-11-01 17:54:22 -04:00
The current implementation of _sshfs_ and _scp_ do not support the copy of
_xattr_ properties. If you want to copy files to a remote machine and
include the _xattr_ comments, use _rsync_ with the _-X_ option. Or _tar_ of course.
2022-10-03 08:19:35 -04:00
2022-11-01 17:54:22 -04:00
Some editing apps (like _vim_ ) will create a new file when saving the data,
which orphans the _xattr_ comments. For these apps, use the _database_ system.
Of course, once you start to manipulate _xattr_ comments outside of the **dirnotes**
programs, the _xattr_ comments will become out of sync with the _database_ comments.
2022-10-03 08:19:35 -04:00
## database
2022-11-01 17:54:22 -04:00
Comments stored in the database work for all filesystem types
(including vfat/exfat/sshfs)
Comments are usually stored in a _per user_ database; thus another user on
the same system will not see these comments.
2022-10-03 08:19:35 -04:00
Files are indexed by their complete path name. Removable filesystems should be
mounted in a consistent way, so that the complete path name is reproducable.
2022-11-01 17:54:22 -04:00
If you are using _sshfs_ , you can use the **dirnotes** programs to copy a file,
and the database comments will work properly.
2022-10-03 08:19:35 -04:00
Comments stored in the database do not travel with the files when
2022-11-01 17:54:22 -04:00
they are moved or copied outside of using the **dirnotes** -family of tools.
2022-10-03 08:19:35 -04:00
# OPTIONS
2022-11-01 17:54:22 -04:00
** -a**
: append to a comment on a file
2022-10-03 08:19:35 -04:00
** -c**
: add a comment to a file
** -C**
2022-11-01 17:54:22 -04:00
: attempt to copy the file(s) and comments to a destination; if multiple files are copied, the destination must be a directory; the last argument is the destination
2022-10-03 08:19:35 -04:00
** -d**
: use database comments as the primary source; cannot be used with ** -x**
2022-11-01 17:54:22 -04:00
** -D**
: print debugging information
2022-10-03 08:19:35 -04:00
** -e**
2022-11-01 17:54:22 -04:00
: erase the comments on the file(s)
2022-10-03 08:19:35 -04:00
** -h** ** --help**
: display help and usage
** -H**
2022-11-01 17:54:22 -04:00
: output the history of comments for the file(s)
2022-10-03 08:19:35 -04:00
** -j**
2022-11-01 17:54:22 -04:00
: output (to stdout) the file comment in .json format
2022-10-03 08:19:35 -04:00
** -l**
: list all files, including those without _dirnotes_ comments
** -M**
: move the file(s) and comments to the destination; if multiple files are moved, the destination must be a directory
** -n**
: output only the comment; this may be useful for scripting
** -v**
2022-11-01 17:54:22 -04:00
: list full path names, also include the comment author and date in the output
2022-10-03 08:19:35 -04:00
** -V** ** --version**
: display version number
** -x**
: use xattr comments as the primary source; connot be used with ** -d**
2022-11-01 17:54:22 -04:00
** -y**
: allow file overwrite for ** -C** copy or ** -M** move
2022-10-03 08:19:35 -04:00
** -z**
2022-11-01 17:54:22 -04:00
: erase history comments associated with the file(s); keep the current comment
2022-10-03 08:19:35 -04:00
** -Z**
: erase all the historic comments in the user's database
# EXAMPLES
To display the comment for a file:
2022-11-01 17:54:22 -04:00
> <code>$ dirnotes-cli car_notes.txt</code>
> <code>car_notes.txt: 'notes on the car repair'</code>
2022-10-03 08:19:35 -04:00
To extract _only_ the comment from a file, use the _-n_ option (useful for scripts):
2022-11-01 17:54:22 -04:00
> <code>$ dirnotes-cli -n car_notes.txt</code>
> <code>notes on the car repair</code>
2022-10-03 08:19:35 -04:00
Or, in json format:
2022-11-01 17:54:22 -04:00
> <code>$ dirnotes-cli -j car_notes.txt</code>
> <code>[{"file": "car_notes.txt", "comment": "notes on the car repair"}]</code>
To append to a comment:
2022-10-03 08:19:35 -04:00
2022-11-01 17:54:22 -04:00
> <code>$ dirnotes-cli -a 'first quote: \$1,400' car_notes.txt</code>
> <code>$ dirnotes-cli car_notes.txt</code>
> <code>car_notes.txt: 'notes on the car repair; first quote: $1,400'</code>
2022-10-03 08:19:35 -04:00
# SEE ALSO
dirnotes, dirnotes-tui, dirnotes-cli
The **dirnotes** program provides a GUI for accessing the files descriptions.
The **dirnotes-tui** program provides a **curses** based (terminal) access to the descriptions.
The **dirnotes-cli** program provides command line access, and can be scripted.
# CONFIGURATION FILE
By default, the file ** ~/.dirnotes.conf** will be used to load the user's config. There are
three attributes described in that file that are important:
2022-11-01 17:54:22 -04:00
> * xattr_tag [default: user.xdg.comment]
> * database [default: ~/.local/share/dirnotes/dirnotes.db]
> * start_mode [default: xattr]
2022-10-03 08:19:35 -04:00
2022-11-01 17:54:22 -04:00
The default location for the config file is ~/.config/dirnotes/dirnotes.conf
2022-10-03 08:19:35 -04:00
2022-10-08 11:32:53 -04:00