A CLI tool to organize (segregate) files into categories.
- Organize by Category: Automatically sort files into folders like Images, Documents, Audio, Videos, Code, Archives, etc.
- Organize by Date: Sort files into Year/Month folders based on modification date
- Recursive Mode: Organize files in subdirectories too (NEW!)
- Dry Run Mode: Preview what would happen without making changes
- Interactive Mode: Confirm each file move individually
- Custom Config: Define your own categories via JSON config file
- Ignore Patterns: Skip files matching specific patterns
- Undo Support: Revert the last organization operation
- Progress Bar: Visual feedback during organization
- Professional Output: Clean, professional CLI output
- Node.js >= 18 (Node 20 LTS recommended)
- npm >= 8
Run directly using npx - no installation needed:
npx segre ./my-folderInstall once and use anywhere on your system:
npm install -g segreAfter global installation, you can use segre command from any directory.
# Clone and install locally
npm install
npm link# Organize files in a directory
segre ./my-folder
# Preview changes without moving files
segre ./my-folder --dry-run
# Organize with verbose output
segre ./my-folder --verbose# Organize files in subdirectories too
segre ./my-folder --recursive
# Combine with other options
segre ./my-folder --recursive --dry-run# Sort files into Year/Month folders
segre ./my-folder --by-date# Confirm each file move
segre ./my-folder --interactive# Ignore specific patterns
segre ./my-folder --ignore "*.log,*.tmp,node_modules"# Generate a sample config file
segre init-config
# Use custom categories
segre ./my-folder --config ./segre.config.json# Show default categories
segre categories
# Show custom categories
segre categories --config ./segre.config.json# Restore files to original locations
segre undo ./my-folder| Option | Alias | Description |
|---|---|---|
--config <path> |
-c |
Path to custom categories config file (JSON) |
--dry-run |
-d |
Show what would happen without moving files |
--interactive |
-i |
Ask before moving each file |
--by-date |
-b |
Organize files by modification date (Year/Month) |
--recursive |
-r |
Recursively organize files in subdirectories |
--ignore <patterns> |
Comma-separated patterns to ignore | |
--verbose |
-v |
Show detailed output |
| Command | Description |
|---|---|
segre <directory> |
Organize files in directory |
segre undo <directory> |
Undo last organization |
segre categories |
Show file categories |
segre init-config [path] |
Generate sample config file |
- Archives: .zip, .tar, .gz, .rar, .7z, .bz2, .xz
- Audio: .mp3, .wav, .flac, .aac, .ogg, .wma, .m4a
- Code: .js, .ts, .css, .html, .py, .java, .cpp, .c, .h, .jsx, .tsx, .vue, .rb, .go, .rs, .php, .swift, .kt
- Documents: .pdf, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .txt, .rtf, .odt, .ods, .odp, .md, .csv
- Executables: .exe, .msi, .dmg, .app, .deb, .rpm, .sh, .bat, .cmd
- Fonts: .ttf, .otf, .woff, .woff2, .eot
- Images: .jpg, .jpeg, .png, .gif, .bmp, .tiff, .svg, .webp, .ico, .raw, .psd, .ai
- Videos: .mp4, .mkv, .avi, .mov, .wmv, .flv, .webm, .m4v, .mpeg, .mpg
- Others: Files that don't match any category
{
"Images": [".jpg", ".jpeg", ".png", ".gif", ".webp"],
"Documents": [".pdf", ".doc", ".docx", ".txt", ".md"],
"Audio": [".mp3", ".wav", ".flac"],
"Videos": [".mp4", ".mkv", ".avi"],
"Code": [".js", ".ts", ".py", ".java"],
"Archives": [".zip", ".rar", ".7z"],
"MyCustomCategory": [".custom", ".myext"],
"Others": []
}segre/
├── bin/
│ └── segre.js # CLI entry point
├── src/
│ ├── index.js # Main exports
│ ├── categories.js # Category definitions
│ ├── cli.js # CLI commands
│ ├── config.js # Config loading
│ ├── logger.js # Operation logging
│ ├── organizer.js # Core logic
│ ├── utils.js # Utility functions
│ └── index.test.js # Tests
├── package.json
└── README.md
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watchMIT License - see LICENSE for details.
Shubham Pawade
Made with ❤️ by Shubham Pawade