Skip to content

Rule Types & Matchers

Matchers reference

type

Whether to match files or directories. Defaults to file.

ValueDescription
file (default)Matches regular files only
dirMatches directories only
match:
type: "dir"
pattern: "^AppIcons$"

When type: dir is set, extensions, min_size, max_size, older_than, and newer_than are ignored — only pattern applies.


extensions

Match files by extension. Case-insensitive. Leading dot is optional in the config but recommended.

match:
extensions: [".pdf", ".docx", ".xlsx"]

pattern

Match the filename (not the full path) against a regular expression.

match:
pattern: "^Screenshot.*" # files starting with "Screenshot"
pattern: ".*_backup\\.(zip|tar\\.gz)$" # backup archives

min_size / max_size

Match files by size. Supports B, KB, MB, GB, TB.

match:
min_size: "500MB" # larger than 500 MB
max_size: "2GB" # smaller than 2 GB

older_than / newer_than

Match files by their last modification time. Supports d (days), w (weeks), and Go duration syntax.

match:
older_than: "90d" # not modified in the last 90 days
newer_than: "7d" # modified within the last 7 days

Scope

Restrict which directories a rule applies to. Scope has two independent properties:

scope.dirs

Directories the rule applies to when running ordr clean manually. When empty, the rule applies everywhere.

scope:
dirs:
- "~/Desktop"
- "~/Downloads"

scope.watch_dirs

Directories the rule monitors when ordr watch is running. Completely independent from scope.dirs — no fallback. If watch_dirs is not set, the rule is inactive during watch mode.

scope:
dirs: ["~/Downloads"]
watch_dirs: ["~/Downloads", "~/Desktop"]

This gives you full independent control:

# Restrict ordr clean to Downloads, also watch Downloads and Desktop
scope:
dirs: ["~/Downloads"]
watch_dirs: ["~/Downloads", "~/Desktop"]
# No scope.dirs — ordr clean applies this rule anywhere, ordr watch only on Desktop
scope:
watch_dirs: ["~/Desktop"]
# Restrict ordr clean to Downloads only, not watched at all
scope:
dirs: ["~/Downloads"]

Paths support ~ for the home directory. Both absolute and relative paths are accepted.


Options

on_conflict

What to do when a file already exists at the destination.

ValueBehavior
rename (default)Appends (1), (2), etc.
skipLeaves the source file untouched
overwriteReplaces the destination file
options:
on_conflict: "skip"

recursive

When true, the rule also applies to files in subdirectories of the target directory.

options:
recursive: true

action

Controls what happens when a directory rule matches. Only applies when match.type: dir.

ValueBehavior
move (default)Moves the entire directory as a unit
flattenExtracts all top-level files from the directory into target
options:
action: "flatten"

remove_empty

Only applies when action: flatten. When true, the source directory is deleted after extraction if it is empty.

options:
action: "flatten"
remove_empty: true

Combining matchers

All matchers are AND-combined. This rule matches .mp4 files that are over 500 MB and older than 90 days:

- name: "Old large videos"
target: "~/Archive/Videos"
match:
extensions: [".mp4", ".mov", ".mkv"]
min_size: "500MB"
older_than: "90d"