Skip to content

JSON Configuration Options

Sam Matzko edited this page Dec 20, 2021 · 1 revision

This page explains how to write a JSON config file to set the sorting algorithm.

template.json

In the Sortery directory, there is a file named template.json. This JSON file is an example of the structure required for a JSON config file. This is what template.json looks like:

{
    "date_format": "%Y-%m-%d %Hh%Mm%Ss",
    "date_type": "m",
    "exclude_type": ["png"],
    "only_type": ["json", "py"],
    "preserve_name": false
}

Note that although the command-line arguments use hyphens - to separate words, due to the structure of the JSON parser, all JSON config options must use underscores _ instead. Below are explanations of each item in the JSON file, and how to use them.

The date_format item

This corresponds with the date-format command-line option. This value takes any value that date-format takes, and must be a string.

The date_type item

This corresponds with the date-type command-line option. This value takes any value that date-type takes, and must be a string. The three date_type options are explained as follows:

Option How it sorts
a Sort all the files by access time: the last time each file was accessed.
c Sort all the files by creation time: the time each file was created.
m Sort all the files by modification time: the time each file was last modified.

The exclude_type item

This corresponds with the exclude-type command-line option. This value is a list of any file extensions (jpg, odt, etc.) to be excluded from the sorting. Each item in the list must be a string, and must be separated from other items by a comma, as per proper JSON formatting.

The only_type item

This corresponds with the only-type command-line option. This value is a list of any file extensions (jpg, odt, etc.) to be exclusively sorted. Each item in the list must be a string, and must be separated from other items by a comma, as per proper JSON formatting. Note that this item overrides the exclude_type item.

The preserve_name item

This corresponds with the preserve-name flag. This value sets whether to preserve the original file name after the date when sorting, and is a bool. It must be one of either true or false (JSON is case-sensitive).

Clone this wiki locally