A fast, flexible command-line tool to automatically organize files into folders based on various strategies.
- Multiple organization strategies: Organize files by extension, date, size, or type
- Dry-run mode: Preview changes before applying them
- Recursive processing: Optionally process subdirectories
- Conflict handling: Automatically renames files to avoid overwrites
- Zero dependencies: Uses only Go standard library
git clone https://github.com/file-organizer/file-organizer.git
cd file-organizer
go build -o file-organizer .go install github.com/file-organizer@latestfile-organizer [options]| Flag | Description | Default |
|---|---|---|
-source |
Source directory to organize | . (current directory) |
-dest |
Destination directory | Same as source |
-strategy |
Organization strategy | extension |
-dry-run |
Preview changes without moving files | false |
-recursive |
Process subdirectories | false |
-verbose |
Show detailed output | false |
-version |
Show version information |
Organizes files by their file extension.
Downloads/
├── report.pdf
├── photo.jpg
└── notes.txt
# After: file-organizer -source Downloads -strategy extension
Downloads/
├── pdf/
│ └── report.pdf
├── jpg/
│ └── photo.jpg
└── txt/
└── notes.txt
Organizes files by modification date (YYYY/MM format).
Photos/
├── vacation.jpg (modified: 2024-06-15)
├── birthday.jpg (modified: 2024-01-20)
└── christmas.jpg (modified: 2023-12-25)
# After: file-organizer -source Photos -strategy date
Photos/
├── 2024/
│ ├── 06/
│ │ └── vacation.jpg
│ └── 01/
│ └── birthday.jpg
└── 2023/
└── 12/
└── christmas.jpg
Organizes files by size categories.
| Category | Size Range |
|---|---|
| tiny | < 10 KB |
| small | 10 KB - 1 MB |
| medium | 1 MB - 100 MB |
| large | 100 MB - 1 GB |
| huge | > 1 GB |
Files/
├── config.txt (500 bytes)
├── document.pdf (2 MB)
└── video.mp4 (500 MB)
# After: file-organizer -source Files -strategy size
Files/
├── tiny (< 10KB)/
│ └── config.txt
├── medium (1MB - 100MB)/
│ └── document.pdf
└── large (100MB - 1GB)/
└── video.mp4
Organizes files by type category.
| Category | Extensions |
|---|---|
| documents | pdf, doc, docx, txt, xls, xlsx, ppt, pptx, etc. |
| images | jpg, png, gif, svg, webp, heic, psd, etc. |
| videos | mp4, avi, mkv, mov, webm, etc. |
| audio | mp3, wav, flac, aac, ogg, etc. |
| archives | zip, rar, 7z, tar, gz, etc. |
| code | go, py, js, ts, java, c, cpp, html, css, json, etc. |
| executables | exe, msi, app, apk, jar, etc. |
| fonts | ttf, otf, woff, woff2, etc. |
| other | Everything else |
file-organizer -source ~/Downloads -strategy extensionfile-organizer -source ~/Downloads -strategy type -dry-runfile-organizer -source ~/Photos -dest ~/Photos/Organized -strategy datefile-organizer -source ~/Documents -strategy type -recursive -verboseRun the test suite:
go test ./...Run with verbose output:
go test -v ./...MIT License - see LICENSE for details.