A CLI tool that organizes files in a directory into subdirectories based on configurable criteria: file extension, modification date, or file size.
go install github.com/Goku-kun/fileorg/cmd/fileorg@latestThis installs the binary to $GOPATH/bin (usually ~/go/bin).
Make sure ~/go/bin is in your PATH. Add this to your ~/.zshrc or ~/.bashrc:
export PATH="$PATH:$HOME/go/bin"Then reload your shell:
source ~/.zshrc # or source ~/.bashrc# Clone and navigate to the project root
cd /path/to/fileorg/root
# Build the binary
go build -o fileorg ./cmd/fileorg
# Move to a directory in your PATH
sudo mv fileorg /usr/local/bin/
# Or add current directory to PATH temporarily
export PATH="$PATH:$(pwd)"go run ./cmd/fileorg [flags] <directory>fileorg [flags] <directory>| Flag | Short | Description |
|---|---|---|
--by |
Organization strategy: extension (default), date, or size |
|
--dry-run |
Preview changes without moving files | |
--verbose |
Show detailed output |
# Organize by file extension (default)
fileorg ~/Downloads
# Preview what would happen (dry run)
fileorg --dry-run ~/Downloads
# Organize by modification date (YYYY-MM folders)
fileorg --by date ~/Downloads
# Organize by file size (small/medium/large folders)
fileorg --by size ~/Downloads
# Verbose output
fileorg --verbose ~/Downloads
# Combine flags
fileorg --dry-run --verbose --by date ~/DownloadsGroups files by their extension:
Downloads/
├── pdf/
│ └── report.pdf
├── jpg/
│ └── photo.jpg
└── misc/
└── README
Groups files by modification date (YYYY-MM):
Downloads/
├── 2026-01/
│ └── recent.pdf
└── 2025-06/
└── old-file.txt
Groups files by size:
| Category | Size Range |
|---|---|
| small | < 1 MB |
| medium | 1 MB - 100 MB |
| large | > 100 MB |
Downloads/
├── small/
│ └── notes.txt
├── medium/
│ └── document.pdf
└── large/
└── video.mp4
- Skips hidden files (starting with
.) - Handles filename collisions (appends
_1,_2, etc.) - Dry-run mode for safe previews
- Graceful error handling
- Exit codes: 0 (success), 1 (error)
# Run tests
go test ./internal/organizer/...
# Run tests with verbose output
go test -v ./internal/organizer/...
# Build
go build ./cmd/fileorg
# Format code
go fmt ./...
# Vet code
go vet ./...fileorg/
├── cmd/fileorg/main.go # CLI entry point
├── internal/organizer/
│ ├── file.go # FileInfo struct
│ ├── organizer.go # Core organization logic
│ ├── organizer_test.go # Tests for safePath
│ ├── strategies.go # Strategy interface + implementations
│ └── strategies_test.go # Strategy tests
├── go.mod
└── README.md