File Organizer
Overview
Systematic file organization for macOS and Linux. Analyze → categorize → plan → confirm → execute → verify. Every destructive operation requires explicit user approval.
First step: Detect the platform (uname -s) and use the matching command variants from commands-reference.md. If a required tool is missing, stop and explain — never guess.
When to Use
- Downloads folder overflowing with months/years of unsorted files
- Can't find files because they're scattered across directories
- Duplicate files wasting disk space
- Folder structure grown organically and no longer makes sense
- Preparing to archive old projects or migrate machines
- Setting up organization for a new directory
When NOT to use:
- Git repository internals (use git tools instead)
- Application data directories (
~/Library/on macOS,~/.local/share/on Linux) - Cloud-synced directories you don't own (shared team drives)
Quick Reference
| Phase | Action | Key Rule |
|-------|--------|----------|
| Scope | Ask: which directory, what problem, what to avoid, how aggressive | Never assume — always confirm scope |
| Detect | Run uname -s to determine macOS vs Linux | Use matching command variants from reference |
| Analyze | Survey file types, sizes, dates using safe read-only commands | See commands-reference.md for platform-specific commands |
| Categorize | Group by type, purpose, or date | Match user's mental model, not yours |
| Plan | Present tree diagram + change list + "needs decision" bucket | User must approve before any changes |
| Execute | mkdir -p then mv with logging | One category at a time; stop on conflicts |
| Verify | Show before/after summary + maintenance tips | Confirm nothing was lost |
Safety Rules (NON-NEGOTIABLE)
- Always confirm before any
mv,rm, or rename operation - Never delete without asking — prefer archiving over deletion
- Exclude dangerous paths:
.git/,.dotfiles/,node_modules/, bare repo metadata - Stay on the filesystem — use
find -x(macOS) orfind -xdev(Linux) to prevent scanning mounted volumes, network shares, or backup trees - Quote all paths — spaces, special chars, and option-like names break unquoted commands
- Warn about cloud storage — on macOS,
file/md5/catcan trigger downloads of iCloud-evicted files. Check for dataless stubs first. - Preserve timestamps — use
mv(preserves by default) orcp -pwhen copying - Log all moves — maintain a record so operations can be reversed
- Handle dotfiles explicitly —
du *andls *skip hidden files;findincludes them. Be consistent. - Never touch bare git repos —
~/.dotfilesand similarGIT_DIRsetups look like junk but are critical infrastructure
Common Mistakes
| Mistake | Fix |
|---------|-----|
| Using GNU-only find -printf on macOS | BSD find has no -printf. Use stat or -exec basename. See commands-reference.md |
| Scanning without filesystem boundary flag | Accidentally includes mounted volumes and backups. Always use -x (macOS) or -xdev (Linux) |
| Wrong md5/md5sum pipeline for dedup | macOS uses md5 -r, Linux uses md5sum. Output format differs — see reference for correct awk pipeline |
| Deleting "duplicates" that are hardlinks | Check inodes first — see hardlink check in reference |
| Running du -sh * for size survey | Misses hidden directories. Use du -shx .[!.]* * or explicit find |
| Organizing inside app data dirs | ~/Library/ (macOS) and ~/.local/share/ (Linux) — reorganizing breaks apps |
| Moving cloud-synced files without warning | Triggers re-sync; can delete across devices if not careful |
Reference Files
commands-reference.md— platform-aware commands for analysis, duplicate detection, and organization. Shows macOS/Linux variants where they differ, portable commands where they don't.