Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Templates

Templates allow you to use dynamic values in action parameters like destination paths and new filenames. Variables are replaced with actual values when the action executes.

Syntax

Template variables use the ${variable} syntax:

- move: ~/Archive/%Y/%m
- rename: "${name}_backup${ext}"

File variables

variabledescriptionexample
${name}Filename without extensiondocument
${ext}File extension (with dot).pdf

Examples

For a file named report.pdf:

templateresult
${name}report
${ext}.pdf
${name}${ext}report.pdf
${name}_copy${ext}report_copy.pdf
backup_${name}${ext}backup_report.pdf

Time variables

Time variables use strftime format tokens:

tokendescriptionexample
%YYear (4 digits)2024
%mMonth (01-12)03
%dDay (01-31)15
%HHour (00-23)14
%MMinute (00-59)30
%SSecond (00-59)45

Common Patterns

patternexample output
%Y-%m-%d2024-03-15
%Y%m%d20240315
%Y/%m/%d2024/03/15
%H:%M:%S14:30:45
%Y%m%d_%H%M%S20240315_143045

Additional Time Tokens

tokendescriptionexample
%yYear (2 digits)24
%BMonth name (full)March
%bMonth name (abbr)Mar
%AWeekday name (full)Friday
%aWeekday name (abbr)Fri
%jDay of year (001-366)074
%UWeek number (00-53)11
%WWeek number (Monday start)10

Examples

Organize by date

rules:
  - name: Organize Downloads
    locations: ~/Downloads
    actions:
      - move: ~/Archive/%Y/%m/%d

Files are organized into folders like ~/Archive/2024/03/15/.

Add timestamp to filename

rules:
  - name: Timestamp Files
    locations: ~/Documents
    filters:
      - extension: pdf
    actions:
      - rename: "${name}_%Y%m%d${ext}"

report.pdf becomes report_20240315.pdf.

Create dated copies

rules:
  - name: Daily Backup
    locations: ~/Documents
    actions:
      - copy: "${name}_%Y%m%d${ext}"

Creates a timestamped copy of each file in the same directory.

Organize photos by date

rules:
  - name: Organize Photos
    locations: ~/Downloads
    filters:
      - extension: [jpg, jpeg, png, heic]
    actions:
      - move: ~/Pictures/%Y/%B

Photos organized into folders like ~/Pictures/2024/March/.

Archive old files

rules:
  - name: Archive Old Downloads
    locations: ~/Downloads
    filters:
      - date_modified:
          before:
            days_ago: 30
    actions:
      - move: ~/Archive/Downloads/%Y-%m

Unique filenames with timestamp

rules:
  - name: Rename Duplicates
    locations: ~/Downloads
    actions:
      - rename: "${name}_%Y%m%d_%H%M%S${ext}"

Combining variables

Mix file and time variables:

- move: ~/Archive/%Y/${name}/%m
- rename: "${name}_%Y%m%d_%H%M%S${ext}"
- copy: "${name}_backup_%Y%m%d${ext}"

Where templates work

Templates are supported in:

actionfields
movedest
copynew_name
renamenew_name
logmsg

Notes

  • Time values are evaluated at action execution time
  • File variables (${name}, ${ext}) come from the matched file
  • Unknown variables are left unchanged in the output
  • Paths are created automatically if they don’t exist