Configuration
forg is controlled by a simple JSON configuration file located at ~/.forg/config.json.
Structure
The configuration is an array of objects. Each object represents a rule with two properties:
pattern: A Rust-flavor regex pattern to match filenames.path: The destination directory (relative to your Home directory).
Example config.json
[
{
"pattern": ".*Screenshot.*",
"path": "Desktop/Screenshots"
},
{
"pattern": ".*\\.(png|jpeg|jpg)$",
"path": "Pictures"
},
{
"pattern": ".*\\.pdf$",
"path": "Documents/PDFs"
}
]
JSON-Specific Rules
Escaping Backslashes
In JSON, the backslash \ is an escape character. Since regex often uses backslashes (e.g., \. to match a literal dot), you must double-escape them:
- Use
\\.pdfinstead of\.pdf.
No Glob Support
As of now, forg does not support shell-type glob-patterns (like *.pdf, etc.). You must use proper regex patterns (as shown in the examples) to define your rules.
Pathing
- Relative to Home: All paths in
config.jsonare automatically prefixed with your Home directory (~). - No Leading Slash: Do not start your path with a
/.- ✅
Pictures - ❌
/Pictures
- ✅
Priority
Rules are matched from top to bottom. The first rule that matches a file's name determines where that file will be moved. Once a match is found, forg stops evaluating further rules for that specific file.
Default Rules
Upon running forg init, a default configuration is generated that covers most common file types:
- Pictures: Screenshots, PNG, JPG, etc.
- Videos: MP4, MKV, MOV, etc.
- Music: MP3, WAV, FLAC, etc.
- Documents: PDFs, DOCX, TXT, CSV, etc.
- Archives: ZIP, TAR, RAR, etc.
- Installers: DMG, PKG, EXE, etc.