← back to Desktop Sorter

README.md

32 lines

# desktop-sorter

Keeps loose items on the Desktop for **3 days**, then files them into category
subfolders by type. Runs daily at **9:00 AM** via launchd.

## Rules
- **Age:** an item is swept once its last-modified time (mtime) is ≥ 3 days old.
  Anything you touched in the last 3 days stays on the Desktop.
- **Always excluded:** `.app` bundles, symlinks/aliases, dotfiles, and the
  category buckets themselves.
- **Categories (Desktop subfolders):**
  `Images Videos Audio Documents Data Web Scripts Folders Misc`
- **Reversible:** every move is appended to `logs/sort-YYYY-MM-DD.log`
  (`<file> -> <Category>/`), so any move can be undone by reading the log.

## Usage
```sh
DRY_RUN=1 ./sort-desktop.sh   # preview, moves nothing
./sort-desktop.sh             # live run
AGE_DAYS=7 ./sort-desktop.sh  # override the 3-day threshold
```

## launchd
- Job: `com.steve.desktop-sorter`
- Plist: `~/Library/LaunchAgents/com.steve.desktop-sorter.plist`
- Reload after edits:
  ```sh
  launchctl bootout  gui/$(id -u) ~/Library/LaunchAgents/com.steve.desktop-sorter.plist 2>/dev/null
  launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.steve.desktop-sorter.plist
  ```
- Run now: `launchctl kickstart -k gui/$(id -u)/com.steve.desktop-sorter`