Patterns
A pattern is a file name with holes in it. tsoqna fills the holes from each file’s metadata.
The basics#
Anything in curly braces is a token; everything else is copied literally. The default pattern is:
{date}_{time}{ext}
which turns IMG_4471.HEIC, taken at 09:31:12 on 14 August 2026, into 2026-08-14_093112.heic. Extensions are lower-cased by default; use {EXT} to keep the original case.
Tokens#
| Token | Example | Meaning |
|---|---|---|
{date} | 2026-08-14 | Capture date, ISO style |
{time} | 093112 | Capture time, no separators |
{Y} {m} {d} | 2026 08 14 | Year, month, day (zero-padded) |
{H} {M} {S} | 09 31 12 | Hour, minute, second |
{ms} | 420 | Sub-second digits, if the camera records them |
{week} | 33 | ISO week number (since 1.4) |
{quarter} | Q3 | Calendar quarter (since 1.4) |
{make} | Fujifilm | Camera maker, as written in the file |
{model} | X-T30 II | Camera model |
{orig} | IMG_4471 | Original file name without extension |
{seq} | 1 | Counter within the same second; see below |
{ext} | .heic | Extension, lower-case, with the dot |
Custom date formats#
{date} and {time} accept a strftime-style format after a colon:
{date:%d.%m.%Y} 14.08.2026
{date:%Y%m%d}_{time:%H-%M} 20260814_09-31
{date:%a %d %b} Fri 14 Aug
Weekday and month names are always English, regardless of your locale, so the same pattern gives the same names on every machine.
Filters#
Tokens can be passed through filters with a pipe (since 1.1):
| Filter | Example | Result |
|---|---|---|
lower | {make|lower} | fujifilm |
upper | {orig|upper} | IMG_4471 |
slug | {model|slug} | x-t30-ii |
pad:N | {seq|pad:3} | 001 |
?default | {model|slug?unknown} | unknown, when no model is recorded |
Sequence numbers#
Burst shots often share the same second. {seq} counts files that would otherwise get the same name, ordered by sub-second time and then original name. It is empty for the first file, so {date}_{time}{seq|pad:2?}{ext} gives …_093112.jpg, …_09311201.jpg, …_09311202.jpg. If you would rather number every file, use {seq|pad:2} without the trailing ?.
Folder patterns#
tsoqna sort uses a second template, folders, for the directory part. Slashes create subfolders:
tsoqna sort ~/Downloads/card --into ~/Photos --folders "{Y}/{Y}-{m}-{d}"
tsoqna sort ~/Downloads/card --into ~/Photos --folders "{Y}/{quarter}/{model|slug?unknown}"
Characters that are not allowed#
tsoqna replaces characters that are illegal on any common file system (< > : " / \ | ? * and control characters) with -, even on systems that would accept them. That way a library sorted on Linux can be copied to a Windows machine or an SD card without surprises.