Rules Engine | Sortio Documentation

Rules Engine

Create precise, deterministic rules for predictable file organization with exact conditions and actions.

Overview

The Rules Engine lets you create IF/THEN automation rules that execute the same way every time. Unlike AI sorting which interprets intent, deterministic rules follow exact conditions you specify—perfect for compliance workflows, automated pipelines, and situations where consistency is critical.

AI Sorting

Interprets your intent, handles nuance, adapts to context. Great for flexible organization.

Deterministic Rules

Follows exact conditions, same inputs = same outputs. Great for repeatable workflows.

Building Rules

Rules have three components: conditions, logic operators, and actions.

Rule Builder Steps

1
Basic Info

Set a name, description, and priority (lower numbers run first)

2
Conditions

Define what files to match using field + comparator + value

3
Actions

Specify what to do with matches: move, rename, tag, etc.

4
Test & Enable

Use dry-run to preview results, then enable the rule

Condition Fields

Fields are properties of a file that you can test against. Select a field, then choose a comparator and value.

Field Description Example
name Filename (with extension) invoice_2024.pdf
extension File extension (without dot) pdf
size File size in bytes 104857600 (100MB)
file_type General type category document, image, video
mime_type MIME type application/pdf
created_at File creation date Used with date comparators
modified_at Last modified date Used with date comparators

Comparators

Comparators define how to test a field's value. There are 21 comparators organized by type.

String Comparators

EQUALS Exact match (case-sensitive option available)
NOT_EQUALS Does not match exactly
CONTAINS Value appears anywhere in field
NOT_CONTAINS Value does not appear in field
STARTS_WITH Field begins with value
ENDS_WITH Field ends with value
MATCHES_REGEX Matches regular expression pattern

List Comparators

IN Value is in list (e.g., extension IN ["pdf", "docx"])
NOT_IN Value is not in list

Numeric Comparators

GT Greater than (e.g., size GT 104857600 for >100MB)
GTE Greater than or equal
LT Less than
LTE Less than or equal
BETWEEN Value is between two numbers (inclusive)

Boolean Comparators

IS_TRUE Field value is true
IS_FALSE Field value is false
EXISTS Field has a value (not null/empty)
NOT_EXISTS Field is null or empty

Special Comparators

HAS_TAG File has specific Finder tag (macOS)
MODIFIED_WITHIN Modified in last N days (e.g., "30d")
CREATED_WITHIN Created in last N days

Boolean Logic

Combine multiple conditions using boolean operators. You can nest condition groups for complex logic.

ALL

All conditions must match (AND)

Example: name CONTAINS "invoice" AND extension = "pdf"

ANY

At least one condition must match (OR)

Example: extension = "jpg" OR extension = "png"

NONE

No conditions can match (NOT)

Example: NOT (extension = "tmp" OR extension = "bak")

Nested Groups

Create complex logic by nesting condition groups. For example:

ALL OF:
  - name CONTAINS "invoice"
  - ANY OF:
      - extension = "pdf"
      - extension = "docx"

This matches files with "invoice" in the name that are either PDF or DOCX.

Actions

When a file matches your conditions, one or more actions execute in sequence.

MOVE

Move File

Move file to a destination folder. Supports template variables for dynamic paths.

{applied_folder}/Archive/{file_year}
COPY

Copy File

Copy file to destination, keeping the original in place.

RENAME

Rename File

Rename the file using a pattern with template variables.

{file_name}_{year}-{month}-{day}{extension}
TAG

Add Tags

macOS only

Add Finder tags to the file. Modes: add (append), set (replace), or remove.

DELETE

Delete File

Move file to trash. Requires explicit confirmation checkbox. Use with caution.

Sequential Actions

Actions run in order. Enable "Continue on error" to proceed even if an action fails.

Template Variables

Use template variables in MOVE, COPY, and RENAME actions to create dynamic, portable paths.

Path Variables

{applied_folder} The folder the rule is applied to
{file_parent} The file's current parent directory
{file_name} Filename without extension
{file_name_full} Full filename with extension
{extension} File extension (e.g., .pdf)

Current Date Variables

{year} Current year (e.g., 2026)
{month} Current month (01-12)
{day} Current day (01-31)
{date} Full date (YYYY-MM-DD)

File Date Variables

{file_year} Year file was modified
{file_month} Month file was modified
{file_day} Day file was modified
{file_created_year} Year file was created
{file_created_month} Month file was created
{file_created_day} Day file was created

Photo EXIF Variables

For photos with EXIF metadata

{exif_year} Year photo was taken
{exif_month} Month photo was taken
{exif_day} Day photo was taken
{gps_latitude} GPS latitude coordinate
{gps_longitude} GPS longitude coordinate

Execution Modes

Control when rules run relative to AI sorting in Smart Folders.

BeforeAi

Rules run first. Matched files skip AI sorting. Use for files you always want handled a specific way.

AfterAi

AI sorts first, then rules post-process the results. Use for cleanup or additional organization.

OnlyRules

Skip AI entirely. Only deterministic rules run. Use when you want full manual control.

Disabled

Rules don't run. AI handles everything. This is the default mode.

Priority & Stop on Match

Rules execute in priority order (lower numbers first). Enable "Stop on match" to prevent subsequent rules from processing a file after this rule matches.

Dry-Run & Testing

Always test rules before enabling them with dry-run mode.

Dry-Run Mode

Shows exactly which files match your conditions and what actions would be taken—without actually moving or modifying anything. Review the preview, adjust conditions if needed, then enable the rule when satisfied.

Best Practices

  • • Always dry-run new rules before enabling
  • • Start with simple conditions, add complexity gradually
  • • Set priorities carefully when rules might overlap
  • • Use "Stop on match" to prevent rule conflicts
  • • Check the activity log to verify rules work as expected

Example Rules

Invoice Organization

PDFs containing "invoice" → Finance/{year}/Invoices

Conditions: ALL OF
  - name CONTAINS "invoice" (case insensitive)
  - extension IN ["pdf", "docx"]

Actions:
  1. MOVE → {applied_folder}/Finance/{file_year}/Invoices

Screenshot Management

Screenshots → Screenshots/{date} with timestamp rename

Conditions: ALL OF
  - name STARTS_WITH "Screenshot"
  - extension IN ["png", "jpg"]

Actions:
  1. MOVE → {applied_folder}/Screenshots/{file_year}-{file_month}-{file_day}
  2. RENAME → {file_name}_{year}{month}{day}{extension}

Large File Archival

Files over 100MB modified in last 30 days → Archive

Conditions: ALL OF
  - size GT 104857600 (100MB in bytes)
  - modified_at MODIFIED_WITHIN "30d"

Actions:
  1. MOVE → {applied_folder}/Archive/{file_year}
  2. TAG → ["archived", "large-file"]

Photo Organization by EXIF Date

Organize photos by the date they were taken

Conditions: ALL OF
  - extension IN ["jpg", "jpeg", "png", "heic"]

Actions:
  1. MOVE → {applied_folder}/Photos/{exif_year}/{exif_month}