Rule Types & Matchers
Matchers reference
type
Whether to match files or directories. Defaults to file.
| Value | Description |
|---|---|
file (default) | Matches regular files only |
dir | Matches 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 archivesmin_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 GBolder_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 daysScope
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 Desktopscope: dirs: ["~/Downloads"] watch_dirs: ["~/Downloads", "~/Desktop"]
# No scope.dirs — ordr clean applies this rule anywhere, ordr watch only on Desktopscope: watch_dirs: ["~/Desktop"]
# Restrict ordr clean to Downloads only, not watched at allscope: 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.
| Value | Behavior |
|---|---|
rename (default) | Appends (1), (2), etc. |
skip | Leaves the source file untouched |
overwrite | Replaces the destination file |
options: on_conflict: "skip"recursive
When true, the rule also applies to files in subdirectories of the target directory.
options: recursive: trueaction
Controls what happens when a directory rule matches. Only applies when match.type: dir.
| Value | Behavior |
|---|---|
move (default) | Moves the entire directory as a unit |
flatten | Extracts 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: trueCombining 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"