Filesystem Librarian

Build Statuscodecov

Librarian runs pre-configured commands against a group of files that match a set of filters. The group of files is called a library. Librarian can either search for files in a library or watch for when files in the library are created or updated.

To run Librarian once, where it exits after searching through a list of configured libraries, run:

sh fs-librarian single-shot path/to/config.toml

To make Librarian continually watch for when files in configured libraries are created or updated, run:

sh fs-librarian watch path/to/config.toml

Building

You can use the pre-built binaries on the release page or build Librarian on your own. To build Librarian, make sure you have Rust installed on your machine (installation instructions are here) then run:

sh make clean build

The binary target/release/fs-librarian will be generated.

Configuration

An example configuration file can be found here.

Libraries

In the Librarian configuration file, define one or more "libraries" of files. A library is a set of files that match defined search filters. Supported search filters are:

For each of the defined libraries, provide a Tera template (whose syntax is based on Jinja2) of the command that should run when a file is found. The following variables are available to the template:

The following configuration snippet defines a music library which watches for files inside the Downloads and /tmp directories that have MIME types matching the audio/.+ regex (e.g. audio/flac and audio/ogg). When an audio file is found, it is moved to the Music directory:

```toml [libraries.music] command = """ mv "{{ file_path }}" /home/jrogena/Music/ """

[libraries.music.filter] directories = [ "/home/jrogena/Downloads", "/tmp" ] mimetyperegexes = [ "audio/.+" ] ```

Filesystem Watching

The following configurations, related to filesystem watching, are available:

toml [fs_watch] min_command_exec_freq = 60

Considerations

Consider the following when using Librarian:

License

MIT