Skip to content

Conversation

@danielo515
Copy link

FileWatcher Spoon

This PR adds a new spoon for automatic file organization based on pattern matching rules.

Features

  • Automatic file organization with Lua pattern matching (case-insensitive)
  • Desktop notifications when files are moved
  • Automatic conflict resolution - appends numbers to duplicate filenames
  • Tilde expansion support for paths (~ for home directory)
  • Chainable API - all methods return the spoon object

Use Cases

  • Organize downloads automatically (PDFs to Documents, images to Pictures, etc.)
  • Sort screenshots from Desktop to a dedicated folder
  • Project file organization by type
  • Any scenario requiring automatic file sorting based on patterns

Example Usage

hs.loadSpoon("FileWatcher")

-- Watch Downloads folder and organize files
spoon.FileWatcher:watchDirectory("~/Downloads", {
  { pattern = "%.pdf$", destination = "~/Documents/PDFs" },
  { pattern = "%.jpg$", destination = "~/Pictures" },
  { pattern = "%.png$", destination = "~/Pictures" },
  { pattern = "%.zip$", destination = "~/Downloads/Archives" }
})

API Documentation

  • Full API documentation included in docs.json (generated using hs -c "hs.doc.builder.genJSON(...)")
  • Follows Hammerspoon Spoon conventions
  • Includes :init(), :start(), :stop(), :watchDirectory(), :stopWatching(), and :stopAllWatchers() methods

Testing

Tested on macOS with various file types and patterns. Files are moved correctly with proper conflict resolution and notifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant