Skip to content

rename

fialr rename <target> [options]

Rename files using a configurable template pattern. Populates template variables from enrichment metadata and file properties. Dry-run by default.


ArgumentDescription
targetDirectory containing files to rename (required)
OptionDescription
--template PATTERNNaming template (default: {{ date }}-{{ entity | slugify }}-{{ descriptor | slugify }}.{{ ext | lower }})
--executeApply renames (default: dry-run only)
-o, --output PATHWrite rename plan to file
--from PATHApply renames from a previously generated rename plan file
--skip PATTERN [...]Glob patterns for files to skip
--dirsRename directories instead of files
--prefixApply prefix map from schema.yaml (requires --dirs)

Templates use a restricted Liquid-like syntax: variables and filters only. No loops, no macros, no arbitrary code.

Variables are populated from enrichment output and file metadata:

VariableSourceExample
dateDocument subject date (ISO 8601). Format configurable via date_format.2024-03-15
entityPrimary subject or organizationacme-corp
descriptorSemantic description (2-5 words)quarterly-report
versionVersion string (present only when multiple versions coexist)v2
extMIME-derived file extensionpdf
tagsList of semantic tags["invoice", "2024"]
confidenceEnrichment confidence score0.92
hashBLAKE3 hash (first 8 characters)a1b2c3d4
sensitivityTier number2
categorySchema categoryfinancial
original_nameOriginal filenamescan001.pdf
mime_typeMIME typeapplication/pdf
user variablesCustom variables from [naming.variables] in fialr.tomlacme

Filters transform variable values. Chain multiple filters with |:

FilterDescriptionExample
slugifyLowercase, underscore-join, strip special charsAcme Corpacme_corp
lowerLowercasePDFpdf
upperUppercasepdfPDF
truncate: NLimit to N characterslong-namelong
default: VFallback if empty{{ version | default: "v1" }}
firstFirst element of a list["a", "b"]a
lastLast element of a list["a", "b"]b
join: SEPJoin list elements["a", "b"]a-b
replace: OLD, NEWString replacementfoo_barfoo-bar
stripTrim whitespace" text ""text"
format: FMTDate or number formatting2024-03-15Mar 2024

Without --execute, rename shows proposed renames without modifying any files. Each line shows the current filename and the proposed new name.

With --execute, renames are applied. Each rename includes:

  1. BLAKE3 hash verification before rename
  2. Provenance recording (original name preserved in XATTRs and SQLite)
  3. The rename operation
  4. Post-rename verification

The naming pattern, date format, file-type overrides, and user variables are configured in fialr.toml:

[naming]
# Default pattern — all tokens optional
pattern = "{{ date }}-{{ entity | slugify }}-{{ descriptor | slugify }}.{{ ext | lower }}"
# Separators
separator = "-"
word_separator = "_"
# Case
case = "lower"
# Date output format (strftime)
date_format = "%Y-%m-%d"
# Per-directory pattern overrides
[naming.directories]
"receipts" = "{{ date }}-{{ entity | slugify }}-{{ descriptor | slugify }}.{{ ext }}"
"photos/*" = "{{ date }}-{{ descriptor | slugify }}.{{ ext }}"
# File-type pattern overrides
[naming.patterns]
"*.jpg" = "{{ date }}-{{ descriptor | slugify }}.{{ ext | lower }}"
"*.mp3" = "{{ entity | slugify }}-{{ descriptor | slugify }}.{{ ext | lower }}"
# User-defined variables available in all templates
[naming.variables]
project = "acme"
owner = "jane"

The --template flag overrides the config file value. When --template is not provided, the pattern is resolved from config using this priority:

  1. Schema category naming_pattern (per-category override in schema.yaml)
  2. Directory pattern — [naming.directories] glob match
  3. Config [naming.patterns] matching the file extension
  4. Config [naming].pattern (default template)
  5. Hardcoded fallback

With --dirs, rename normalizes directory names instead of files:

  • Applies the configured case and word separator
  • Strips special characters
  • With --prefix, applies prefix_map from schema.yaml (e.g., work/01_work/)
  • Dry-run by default

Dry-run:

rename ~/Documents
RENAME 14 files (dry-run)
────────────────────────────────────────────────────────
scan001.pdf → 2024-03-15-acme-quarterly_report.pdf
IMG_4521.jpg → 2024-06-01-paris-eiffel_sunset.jpg
doc (1).docx → 2024-01-10-smith-employment_contract.docx

Terminal window
# Preview renames (dry-run)
fialr rename ~/Documents
# Apply renames
fialr rename ~/Documents --execute
# Custom template with hash suffix
fialr rename ~/Documents --template "{{ date }}_{{ entity | slugify }}_{{ hash }}.{{ ext | lower }}"
# Minimal template — omit date
fialr rename ~/Documents --template "{{ entity | slugify }}_{{ descriptor | slugify }}.{{ ext }}"
# Photos — date and descriptor only (no entity)
fialr rename ~/Photos --template "{{ date }}_{{ descriptor | slugify }}.{{ ext | lower }}"
# Include a user-defined variable (set in fialr.toml [naming.variables])
fialr rename ~/Documents --template "{{ project }}_{{ date }}_{{ descriptor | slugify }}.{{ ext | lower }}"
# Preview directory renames
fialr rename ~/Documents --dirs
# Apply directory renames
fialr rename ~/Documents --dirs --execute
# Apply prefix map from schema.yaml
fialr rename ~/Documents --dirs --prefix --execute