fileroute
v1.0.1
Published
fileroute — Route files to the right place automatically. Monitor folders, match conditions, run actions. A powerful IF→THEN file automation CLI for Windows, macOS, and Linux.
Maintainers
Readme
📁 fileroute
Route files to the right place — automatically.
fileroute is a fast, lightweight, and intelligent command-line tool that automatically organizes messy directories into clean, structured subfolders. Set it up once, and it routes files like documents, images, videos, audio, code, and archives into their appropriate places.
Features include Watch Mode (Auto-Organize) for real-time file organization, Dry-Run Previews to inspect changes safely, One-Command Undo to revert operations anytime, and Per-Folder Configurations.
📑 Table of Contents
- Package Overview
- Package Description
- Download & Installation
- Initial Setup & Configuration Wizard
- Auto-Organize / Watch Mode
- All Available Commands
- Practical Examples
- Folder Organization Structure
- Configuration Reference
- Safety & Undo System
- Troubleshooting
- Frequently Asked Questions (FAQ)
- Development & Testing
- Package Publishing & Metadata
- License
📦 Package Overview
What it is
fileroute (also accessible via the short command route) is an automated file router and folder organizer built with Node.js.
What Problem it Solves
Over time, folders like Downloads, Desktop, and shared workspaces become cluttered with thousands of unorganized files (PDFs, screenshots, video clips, installers, archives). Finding specific files manually is frustrating and time-consuming. fileroute organizes these folders instantly in a single command or monitors them continuously in the background.
Key Highlights
- 📂 Smart File Classification: Automatically routes files into standard category folders (
Documents,Images,Videos,Audio,Code,Archives,Installers,Fonts,Design,Data). - 👀 Continuous Watch Mode: Automatically detects newly created or downloaded files and moves them instantly.
- 🔍 Safe Previews: Dry-run mode (
preview) shows planned moves without altering your filesystem. - ↩️ One-Command Undo: Every operation writes an undo manifest allowing instant restoration.
- 🛡️ Duplicate File Protection: Handles naming collisions safely by appending numbers (e.g.
file (1).pdf) instead of overwriting existing files. - ⚙️ Per-Folder Settings: Customize organization rules, exclusion globs, and default modes per directory.
Who it is for
- Developers & Designers: Keep workspace directories and asset downloads clean.
- Students & Professionals: Keep documents, invoices, spreadsheets, and slides structured.
- Power Users: Automate continuous cleanup on
DownloadsorDesktopfolders.
📝 Package Description
fileroute transforms chaotic folders into clean, categorized hierarchies based on customizable rule engines:
- Extension Categorization (
--mode type): Maps file extensions (.pdf,.jpg,.mp4,.zip,.js) to designated target folders (Documents,Images,Videos,Archives,Code). - Pattern & Keyword Matching (
--mode name): Detects keywords likescreenshot,invoice,setup,backup,presentationin filenames and routes them to specialized folders. - Date Organization (
--mode date): Groups files into year and month folders based on file modification timestamps (2026/09).
📥 Download & Installation
Prerequisites
- Node.js: Version
16.0.0or higher. - Operating System: Compatible with Windows, macOS, and Linux.
Global Installation (Recommended)
Install fileroute globally using npm to make the fileroute and route commands available anywhere in your terminal:
npm install -g filerouteTry Without Installing (npx)
Run fileroute directly without installing:
npx fileroute ~/Downloads⚙️ Initial Setup & Configuration Wizard
To configure fileroute for any target directory, run the interactive setup wizard:
fileroute setup ~/DownloadsOr run setup for the current folder:
fileroute setupSetup Options Walkthrough
When you run fileroute setup, the CLI presents the following interactive options:
“Do you want to automatically organize your files?”
- Selecting
Yes: Enables Auto-Organize / Watch Mode. Saves"autoWatch": truein.fileroute-config.jsonand immediately launches continuous background folder monitoring. - Selecting
No: Saves"autoWatch": false.filerouteruns only when explicitly triggered by you.
- Selecting
“Default organize mode:”
File type(categorizes by file extension intoDocuments,Images,Videos, etc.)File name pattern(categorizes by keywords likescreenshot,invoice,backup)Modified date(categorizes byYYYY/MMfolders)
“Scan subfolders by default?” (
recursive)- Controls whether
filerouteinspects subdirectories recursively.
- Controls whether
“Include hidden files?” (
includeHidden)- Controls whether dotfiles (e.g.
.gitignore) are included.
- Controls whether dotfiles (e.g.
“Auto-save undo manifest?” (
autoUndo)- Generates manifest history files after every non-dry-run operation for undo capability.
👀 Auto-Organize / Watch Mode
How Watch Mode Works
When Auto-Organize / Watch Mode is activated, fileroute monitors the target directory using chokidar. As soon as a new file finishes downloading or saving into the folder, fileroute detects it automatically and routes it to the correct category subfolder.
Automated Routing Examples
| Incoming File | Detected Extension / Pattern | Destination Subfolder |
| :--- | :--- | :--- |
| report_2026.pdf | .pdf (Document) | Documents/report_2026.pdf |
| vacation_photo.jpg | .jpg (Image) | Images/vacation_photo.jpg |
| tutorial_video.mp4 | .mp4 (Video) | Videos/tutorial_video.mp4 |
| backup_data.zip | .zip (Archive) | Archives/backup_data.zip |
| installer_setup.exe | .exe (Installer) | Installers/installer_setup.exe |
| script.js | .js (Code) | Code/script.js |
| Screen Shot 2026.png | screenshot pattern | Screenshots/Screen Shot 2026.png |
Controlling Watch Mode
- Start Watch Mode directly:
fileroute watch ~/Downloads - Stop Watch Mode: Press
Ctrl + Cin the terminal running Watch Mode.
🛠️ All Available Commands
fileroute provides several CLI commands and short aliases (route is an exact alias for fileroute).
1. fileroute setup [folder]
Runs the interactive setup wizard and prompts for Auto-Organize configuration.
fileroute setup ~/Downloads2. fileroute [folder] / fileroute run [folder]
Organizes the target directory immediately based on active or default rules.
fileroute ~/Downloads
# Or short alias
route ~/Downloads3. fileroute preview [folder] / fileroute --dry-run [folder]
Simulates file organization and displays proposed changes without moving any files.
fileroute preview ~/Downloads4. fileroute watch [folder]
Starts Watch Mode to monitor a directory continuously and organize incoming files on arrival.
fileroute watch ~/Downloads5. fileroute undo [folder]
Restores files moved during the last organization run back to their original locations.
fileroute undo ~/Downloads6. fileroute config [folder]
Views or edits per-folder settings saved in .fileroute-config.json.
fileroute config ~/DownloadsCommand Flags & Options Reference
| Flag / Option | Description | Example |
| :--- | :--- | :--- |
| --target <path> | Specifies the target directory | fileroute --target ~/Desktop |
| --mode <type\|name\|date> | Sets organization mode (type, name, date) | fileroute ~/Downloads --mode date |
| --dry-run | Previews changes without moving files | fileroute run ~/Downloads --dry-run |
| --recursive | Scans subdirectories recursively | fileroute run ~/Desktop --recursive |
| --exclude <globs> | Excludes matching files/folders (comma-separated) | fileroute run ~/Downloads --exclude "*.tmp,node_modules" |
| --include-hidden | Includes hidden files/dotfiles | fileroute run ~/Downloads --include-hidden |
| --no-manifest | Disables manifest creation (prevents undo) | fileroute run ~/Downloads --no-manifest |
| --report <path> | Saves a JSON summary report to specified path | fileroute run ~/Downloads --report report.json |
| --verbose | Displays detailed logging output | fileroute run ~/Downloads --verbose |
| --help, -h | Displays global or command-specific help | fileroute --help |
| --version, -V | Displays installed package version | fileroute --version |
💡 Practical Examples
Scenario 1: Clean Downloads in One Command
fileroute ~/DownloadsResult: Files are scanned and organized into category folders immediately.
Scenario 2: Preview Changes Safely Before Moving
fileroute preview ~/DownloadsResult: Outputs a dry-run plan showing exact proposed moves without altering files.
Scenario 3: Accidental Move? Undo Instantly
fileroute undo ~/DownloadsResult: Reverts the previous run and restores all moved files back to their exact original locations.
Scenario 4: Monitor Downloads Automatically
fileroute watch ~/DownloadsResult: Launches Watch Mode. Leave the process active in your terminal or background to auto-organize new downloads as soon as they arrive.
📂 Folder Organization Structure
Before Organization:
Downloads/
├── invoice_2026.pdf
├── screenshot_1.png
├── holiday_photo.jpg
├── demo_video.mp4
├── archive_files.zip
└── setup_installer.exeAfter fileroute ~/Downloads:
Downloads/
├── Documents/
│ └── invoice_2026.pdf
├── Images/
│ └── holiday_photo.jpg
├── Screenshots/
│ └── screenshot_1.png
├── Videos/
│ └── demo_video.mp4
├── Archives/
│ └── archive_files.zip
└── Installers/
└── setup_installer.exe⚙️ Configuration Reference
When setup or config commands are executed, fileroute creates a .fileroute-config.json file inside the target directory:
{
"version": "1.0.0",
"mode": "type",
"recursive": false,
"includeHidden": false,
"excludePatterns": [],
"autoUndo": true,
"autoWatch": true,
"dryRunByDefault": false
}Configuration Options Breakdown
version: Schema version.mode: Default organize mode (type,name,date).recursive: Whether subfolders are scanned recursively (true/false).includeHidden: Whether dotfiles are scanned (true/false).autoUndo: Whether undo manifests are created (true/false).autoWatch: Whether Watch Mode starts automatically after setup (true/false).excludePatterns: Array of glob strings to ignore.
🛡️ Safety & Undo System
fileroute prioritizes data safety:
- Non-Destructive Operations: Files are moved, never deleted.
- Duplicate Naming Safeguard: If
Documents/report.pdfalready exists, an incoming file is renamed toDocuments/report (1).pdf. - Manifest History: Real runs record file moves inside
.fileroute/manifest-<timestamp>.json. - Instant Restoration:
fileroute undoreads the latest manifest and safely restores every moved file. - Project File Isolation:
filerouteskips project configurations (package.json,index.js,README.md,.git) automatically to prevent self-disruption.
❓ Troubleshooting
1. command not found: fileroute
- Ensure Node.js is installed.
- Re-run
npm install -g filerouteor run vianpx fileroute.
2. Files not moving / skipped
- Run with
--verboseflag (fileroute ~/Downloads --verbose) to inspect skip reasons. - Verify if files match an
--excludepattern or are already inside a managed category folder (Documents,Images, etc.).
3. Permission Errors
- Ensure your user account has write permissions for the target directory.
4. How to Reset Directory Configuration
- Delete the
.fileroute-config.jsonfile in the folder and runfileroute setupagain.
💬 Frequently Asked Questions (FAQ)
Q: Does fileroute delete any of my files?
A: No. fileroute only moves files into subfolders and protects against overwriting duplicates.
Q: How do I stop Watch Mode?
A: Press Ctrl + C in the terminal window running Watch Mode.
Q: Can I use route instead of typing fileroute?
A: Yes! route is an official short alias installed with the package.
Q: Can I customize file categories?
A: Yes, per-folder settings can be configured via fileroute config or by editing .fileroute-config.json.
🧪 Development & Testing
Contributions and local development instructions:
Clone & Install Dependencies
git clone https://github.com/kirtan-kalathiya/fileroute.git
cd fileroute
npm installRun Tests
npm test📌 Package Publishing & Metadata
- npm Package:
fileroute - Repository: github.com/kirtan-kalathiya/fileroute
- Homepage: fileroute.dev
- CLI Executables:
fileroute,route
📄 License
Distributed under the MIT License. Created by kirtan kalathiya.
