[The [MacOS](#macos) stores its comments in a similar way.]
The <code>**dirnotes**</code> app is a GUI app, using the Qt5 framework. At startup, it displays the contents of the current directory, and the comments associated with any of the files or directories.
Simple mouse clicks allow you to tunnel down into directories, or rise up the file system.
You can create/edit comments and choose whether the _xattr_ or _database_ version of the comments take priority,
The <code>**dirnotes-tui**</code> is a very similar app, but uses the _curses_ framework to display its activity in a terminal window. This can be handy if you have to work across a network, or if terminal apps are you preference.
The <code>**dirnotes-cli**</code> is a command line tool, which may be handy for scripting.
The <code>**dirnotes**</code> program displays usage and keystoke info when you press _F1_. The <code>**dirnotes-tui**</code> program display onscreen usage when you press the 'h' key, or _F1_.
The <code>**dirnotes-cli**</code> program has a man page.
automatically preserves _xattr_. Other programs can also be coerced into
perserving _xattr_ properties:
* <code>**rsync**</code>
* <code>**tar**</code>
* <code>**mksquashfs**</code>
Not all file systems support xattr properties (vfat/exfat does not).
The current implementation of <code>**sshfs**</code> and <code>**scp**</code>
do not support the copy of _xattr_ properties.
If you want to copy files to a remote machine and include the _xattr_ comments, use <code>**rsync**</code> with the _-X_ option. Or <code>**tar**</code>.
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.
Removable disk devices (usb sticks) which are formatted with a Linux-based filesystem (ext2/3/4, btrfs, xfs, zfs) will carry the _xattr_ comments embedded in the filesystem metadata, and are portable to anther computer.
The _database_ comments that are stored in <code>~/.dirnotes.db</code> are inherently associated with a single user. If the _database_ is located in <code>/var/lib/dirnotes.db</code>, it is shared by all the users in the system. The comment with the 'most recent timestamp' wins.
to display the comments/author/date on a file. For example:
$ xattr -l /etc/fstab
user.xdg.comment: controls the default mount bindings
user.xdg.comment.author: patb
user.xdg.comment.date: 2022-09-29 08:07:42
The other options on the **xattr** command line tool allow you to write (*xattr -w*) or delete (*xattr -d*) the comments.
* database
The comments are stored in an Sqlite3 database, usually located at "~/.dirnotes.db". The database itself is contained within that file, and its schema is this:
The _date_ and _size_ fields reflect the file's modification date and size at the time of the last edit of the file comment, which is stored in _comment_date_.
As comments are editted or appended, new records are added to the database. Older records are are not purged. This gives you a history of the comments, but it means that fetching the most recent comment involves something like
~~~~
SELECT * FROM dirnotes WHERE name=? ORDER BY comment_date DESC
The **MacOS** inherently supports file comments. The Finder app manages most of the user activity. It handles file comments in a similar manner to **Dirnotes**. Comments are stored in two places:
The user can examine the file comments by opening the GetInfo dialog, and scrolling down to "Comment"
If the Finder is used to copy/move files, the comments are moved properly to both destinations. If you use the os to copy/move the files, you can ask that the xattr properties get moved, but the .DS-Store file will not be updated. That means the Finder will not see file comments on the destination file.
**MacOS** has AppleScript, by which you can ask the Finder to perform the file copy/move. In this case, the comments are moved properly.