/CNOTE

C++ file sort by custom tag

Primary LanguageC++MIT LicenseMIT

C-NOTE

C-NOTE is a file organization tool to help sort files that aren’t easily sorted in directory hierarchies. C-NOTE uses a tagging system, to associate tags with entries; an entry can be a file, directory, or any valid filepath.

How Files May Be Tagged

At startup, the program searches the working directory for files with the tag marker at or near the beginning of the file: #:. It then looks at the rest of the line following this tag marker, and splits it by whitespace into tags.

After all entries in a directory are searched, the .tag file is handled.

Tag Marker at Beginning of File

> example_tagged_file.txt

#: my-tag another-tag some_other<>totally_f*#!$%&_crazy.tag| and'another

... file contents ...

Resulting tags for example_tagged_file.txt:

  • my-tag
  • another-tag
  • some_other<>totally_f*#!$%&_crazy.tag|
  • and'another

For ease of use, C (// or /*), LISP (;), LaTeX (%), and Org mode (#) comment characters are skipped, along with whitespace.

Identical:

  • #: my-tag another-tag
  • #: my-tag another-tag
  • % #: my-tag another-tag
  • %#: my-tag another-tag
  • ;#: my-tag another-tag
  • ;;; #: my-tag another-tag
  • // #: my-tag another-tag
  • //#: my-tag another-tag
  • /*#: my-tag another-tag
  • ### ## ##: my-tag another-tag

The .tag file

However, you may also want to tag files that have strict formats; formats that don’t allow for this tag marker and tags inserted at the beginning. For that, we have a solution: the .tag file.

The .tag file is an associative list of filepaths to lists of tags. This allows files that have a strict format to still be tagged, like png, jpg, pdf, and more!

Example Directory:

a
|-- 1.txt (tagged with "my-tag")
|-- 1.png
|-- 2.txt (tagged with "my-tag another-tag")
|-- b
|   `-- ... lots of files ...
`-- .tag

Example .tag Contents:

1.png #: my-tag
b     #: another-tag

About the .tag Format: there must be whitespace in between the filepath and the tag marker. Multiple files can be tagged by using multiple lines.

Each line has the following general form.

<FILEPATH> <TAG MARKER><TAGS>

In the future we hope to provide a way to allow tagging files from the .tag file with spaces in the path.

Building

Run the following to generate a build tree using the default generator on your system.

cmake -B bld

Then, invoke the build tree to build the CLI program.

cmake --build bld