{"id":13411926,"url":"https://github.com/maid/maid","last_synced_at":"2025-05-13T00:32:12.954Z","repository":{"id":41867563,"uuid":"1780853","full_name":"maid/maid","owner":"maid","description":"Be lazy.  Let Maid clean up after you, based on rules you define.  Think of it as \"Hazel for hackers\".","archived":false,"fork":false,"pushed_at":"2025-03-30T14:29:59.000Z","size":863,"stargazers_count":1866,"open_issues_count":47,"forks_count":84,"subscribers_count":37,"default_branch":"master","last_synced_at":"2025-04-09T02:14:44.225Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://rubygems.org/gems/maid","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maid.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null},"funding":{"buy_me_a_coffee":"benjaminoakes"}},"created_at":"2011-05-21T15:35:43.000Z","updated_at":"2025-04-08T12:17:47.000Z","dependencies_parsed_at":"2024-10-29T10:38:00.389Z","dependency_job_id":null,"html_url":"https://github.com/maid/maid","commit_stats":null,"previous_names":["benjaminoakes/maid"],"tags_count":58,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maid%2Fmaid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maid%2Fmaid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maid%2Fmaid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maid%2Fmaid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maid","download_url":"https://codeload.github.com/maid/maid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250494879,"owners_count":21440060,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:18.634Z","updated_at":"2025-04-23T18:44:57.881Z","avatar_url":"https://github.com/maid.png","language":"Ruby","funding_links":["https://buymeacoffee.com/benjaminoakes"],"categories":["Ruby"],"sub_categories":[],"readme":"# Maid\n\n[![Gem Version](https://badge.fury.io/rb/maid.svg)](https://badge.fury.io/rb/maid)\n[![Test](https://github.com/maid/maid/actions/workflows/test.yml/badge.svg)](https://github.com/maid/maid/actions/workflows/test.yml)\n[![Code Climate](https://codeclimate.com/github/maid/maid.svg)](https://codeclimate.com/github/maid/maid)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/3898063fb5b3caf24044/test_coverage)](https://codeclimate.com/github/maid/maid/test_coverage)\n[![StackOverflow](http://img.shields.io/badge/stackoverflow-maid-blue.svg)](http://stackoverflow.com/questions/tagged/maid)\n\n**Be lazy!**  Let Maid clean up after you, based on rules you define.\n\n[Installation](#installation)\n| [Tutorial](#tutorial)\n| [Example](https://github.com/maid/maid-example)\n| [User Community](https://github.com/maid/maid/wiki)\n| [Documentation][]\n| [Changelog](CHANGELOG.md)\n\nMaid keeps files from sitting around too long, untouched.  Many of the downloads and temporary files you collect can\neasily be categorized and handled appropriately by rules you define.  Let the `maid` in your computer take care of the\neasy stuff, so you can spend more of your time on what matters.\n\nThink of it like the email filters you might already have, but for files.  Worried about things happening that you don't\nexpect?  Maid doesn't overwrite files and actions are logged so you can tell what happened.\n\nMaid is inspired by the Mac OS X shareware program [Hazel](http://www.noodlesoft.com/hazel.php).  Think of Maid as\n**\"Hazel for hackers\"**.\n\nYour rules are defined in Ruby, so simple rules are easy and difficult rules are possible.  This also makes Maid a great\ngeneral-purpose **advanced file renaming tool**.\n\n## Want to help?\n\nThis project wouldn't be where it is today without its users and contributors.  Thank you!  See [AUTHORS][] and the\n[contributors graph][] for more info.\n\n  [authors]: https://github.com/maid/maid/blob/master/AUTHORS.md\n  [contributors graph]: https://github.com/maid/maid/graphs/contributors\n\n### For Users\n\n* Participate in [beta testing](https://github.com/maid/maid/issues/10)\n* [Report an issue](https://github.com/maid/maid/issues) (bug or feature request)\n* Read through the [wiki](https://github.com/maid/maid/wiki)\n* Even just [share a link to Maid](https://twitter.com/intent/tweet?related=maidgem\u0026text=Be+lazy%21+Let+Maid+clean+up+after+you%2C+based+on+rules+you+define\u0026url=https%3A%2F%2Fgithub.com%2Fmaid%2Fmaid) :)\n\n### For Developers\n\n* Address a `TODO` or `FIXME` in the code (list them with `rake notes`.)\n* Fix an [existing issue](https://github.com/maid/maid/issues)\n* **Working on an issue?** Please leave a comment so others know.\n* See the [Contributing guide](https://github.com/maid/maid/wiki/Contributing)\n\n## Buzz\n\n[\n![Hacker News Logo](https://raw.github.com/maid/maid/master/resources/hacker-news.png)\n](http://news.ycombinator.com/)\n\n[Hazel for hackers](http://news.ycombinator.com/item?id=4928605) - December 16th, 2012 (peaked at #2)\n\n[![Ruby5 Logo](https://raw.github.com/maid/maid/master/resources/ruby5.gif)](http://ruby5.envylabs.com/)\n\n[Podcast #302](http://ruby5.envylabs.com/episodes/306-episode-302-august-31st-2012) (at 2:45) - August 31st, 2012\n\n[\n![OneThingWell Logo](https://raw.github.com/maid/maid/master/resources/OneThingWell.png)\n](http://onethingwell.org/)\n\n[Maid](http://onethingwell.org/post/30455088809/maid) - August 29th, 2012\n\n[More...](https://github.com/maid/maid/wiki/In-the-Media)\n\n## Installation\n\nMaid is a gem, so just `gem install maid` like normal.  If you're unfamiliar with Ruby, please see below for details.\n\n#### Requirements\n\nModern Ruby versions and Unix-like operating systems should work, but only OS X and Ubuntu are tested regularly.\n\nOffically supported:\n\n* **OS:** Mac OS X, Ubuntu\n* **Ruby:** 2.7.0+ (3.0.0+ preferred)\n\nSome features require OS X.  See the [documentation][] for more details.\n\n### Manual Installation\n\nFirst, you need Ruby 2.7 or 3. If you're starting without any Rubies, we\nstrongly recommend going for Ruby 3 as 2.7 is EOL.\n\nConsider using [`rvm`](https://rvm.io/rvm/install), [`rbenv`](https://github.com/rbenv/rbenv#installation), [`rtx`](https://github.com/jdxcode/rtx), or [any other version management tool](https://github.com/bernardoduarte/awesome-version-managers).\n\nThen, install via RubyGems.  Open a terminal and run:\n\n```bash\ngem install maid\n```\n\nAt a later date, you can update by running:\n\n```bash\ngem update maid\n```\n\nIf you decide you don't want Maid installed anymore, remove it:\n\n```bash\ngem uninstall maid\n```\n\n**NOTE:** This does not remove any files under `~/.maid` or crontab entries.  Please remove them at your convenience.\n\n### Install through RVM and a dedicated gemset\n\nInstall Ruby 3.2 and create a gemset:\n\n`rvm install ruby-3.2 \u0026\u0026 rvm use 3.2 \u0026\u0026 rvm gemset create maid \u0026\u0026 rvm alias create maid ruby-3.2@maid`\n\nInstall maid:\n\n`rvm use maid \u0026\u0026 gem install maid`\n\nUpdate maid:\n\n`rvm use maid \u0026\u0026 gem update maid`\n\nUpdate ruby:\n\n`rvm install ruby-3.3 \u0026\u0026 rvm gemset copy 3.{2,3}@maid \u0026\u0026 rvm alias maid 3.3@maid`\n\n## Tutorial\n\nIn a nutshell, Maid uses \"rules\" to define how files are handled.  Once you have rules defined, you can either test what\ncleaning would do (`maid clean -n`) or actually clean (`maid clean -f`).\n\nTo generate a [sample rules file](lib/maid/rules.sample.rb), run:\n\n```bash\nmaid sample\n```\n\nMaid rules are defined using Ruby, with some common operations made easier with a small DSL (Domain Specific Language).\n\nFor example, this is a rule:\n\n```ruby\nMaid.rules do\n  rule 'Old files downloaded while developing/testing' do\n    dir('~/Downloads/*').each do |path|\n      if downloaded_from(path).any? {|u| u.match 'http://localhost'} \u0026\u0026 1.week.since?(accessed_at(path))\n        trash(path)\n      end\n    end\n  end\nend\n```\n\nIf you're new to Ruby and would prefer a more traditional `for` loop, you can also do this:\n\n```ruby\nMaid.rules do\n  rule 'My rule' do\n    for path in dir('~/Downloads/*')\n      # ...\n    end\n  end\nend\n```\n\nBefore you start running your rules, you'll likely want to be able to test them.  Here's how:\n\n```bash\n# No actions are taken; you just see what would happen with your rules as defined.\nmaid clean --dry-run # Synonyms: -n, --noop\n```\n\nTo run your rules on demand, you can run `maid` manually:\n\n```bash\nmaid clean -f                 # Run the rules at ~/.maid/rules.rb, logging to ~/.maid/maid.log\nmaid clean -fr some_rules.rb  # Run the rules in the file 'some_rules.rb', logging to ~/.maid/maid.log\n```\n\nSo, for example, if this is `some_rules.rb`:\n\n```ruby\nMaid.rules do\n  rule 'downloaded PDF books' do\n    move(dir('~/Downloads/*.pdf'), '~/Books')\n  end\nend\n```\n\nThen, this is the command to test, as well as some sample output:\n\n```bash\n$ maid clean -nr some_rules.rb\nRule: downloaded PDF books\nmv \"/Users/ben/Downloads/book.pdf\" \"/Users/ben/Books/\"\nmv \"/Users/ben/Downloads/issue12.pdf\" \"/Users/ben/Books/\"\nmv \"/Users/ben/Downloads/spring2011newsletter.pdf\" \"/Users/ben/Books/\"\n```\n\nFor help with command line usage, run `maid help`.  For more help, please see the links at the top of this README.\n\n### Automation\n\nOnce you get a hang for what you can do with Maid, let it do its stuff automatically throughout the day.  You'll find\nyour computer stays a little tidier with as you teach it how to handle your common files.\n\n**Note:** Daemon support (using `fsevent`/`inotify`) was recently added.  That said, `cron` takes care of the needs of many users.\n\nTo do this, edit your crontab in your tool of choice:\n\n```bash\ncrontab -e\n```\n\n...and have it invoke the `maid clean -f` command.  The `--silent` option is provided to keep this from emailing you, if\ndesired.  A log of the actions taken is kept at `~/.maid/maid.log`.\n\nExample for every day at 1am:\n\n```cron\n# minute hour day_of_month month day_of_week command_to_execute\n0 1 * * * /bin/bash -li -c \"maid clean --force --silent\"\n```\n\n### Running as a daemon\n\nTo run Maid as a daemon you first have to specify watch/repeat rules.\n\nThey are defined like this:\n\n```ruby\nMaid.rules do\n  repeat '1s' do\n    rule 'This rule will run every second' do\n      # some task\n    end\n  end\n\n  watch '/home/user/Downloads' do\n    rule 'This rule will run on every change to the downloads directory' do\n      # another task\n    end\n  end\n\n  watch '~/Desktop', ignore: /some_directory/ do\n    # rules in here\n  end\nend\n```\n\nHere's a simple \"watch\" rule that organizes images by dimensions as soon as they're added to `~/Pictures`:\n\n```ruby\nMaid.rules do\n  watch '~/Pictures' do\n    rule 'organize images by dimensions' do\n      where_content_type(dir('~/Pictures/*'), 'image').each do |image|\n        width, height = dimensions_px(image)\n        move(image, mkdir(\"~/Pictures/#{width}x#{height}\"))\n      end\n    end\n  end\nend\n```\n\nThe command to run the daemon is `maid daemon`.  Starting the daemon on login depends on the platform.\n\n#### With RVM and cron\n\nSee [above](#install-through-rvm-and-a-dedicated-gemset) to install RVM and\nmaid in its own gemset.\n\nRun maid daily in a cron:\n\n```cron\n# /etc/cron.daily/maid\n\n#!/usr/bin/env bash\nsudo -Hu \u003cyour username\u003e bash -li -c \"\u003cyour username\u003e/.rvm/wrappers/maid/maid clean --force --silent --rules ~/.maid/rules.rb\"\n```\n\n#### Ubuntu\n\nYou can run `maid daemon` as a normal startup application (Power/Gear Menu -\u003e Startup Applications... -\u003e Add).\n\n#### OS X\n\nPlease see Jurriaan Pruis' blog post, [Maid as a Daemon on OS X](https://web.archive.org/web/20191228181605/jurriaan.ninja/2015/01/01/maid-on-os-x.html).  ([Automating this setup would be welcome as a pull request!](https://github.com/maid/maid/issues/136))\n\n### Rake Tasks\n\nMaid includes helpers that make file managment easier.  You may find them useful if you need to automate tasks in your Ruby projects.  This is available via support for Maid-based Rake tasks:\n\n```ruby\n# File: Rakefile\nrequire 'maid'\n\nMaid::Rake::Task.new :clean do\n  # Clean up Rubinius-compilied Ruby\n  trash(dir('**/*.rbc'))\nend\n```\n\nIn fact, the Maid project uses Maid in [its Rakefile](Rakefile).\n\nYou can also provide a custom description:\n\n```ruby\nMaid::Rake::Task.new clean_torrents: [:dependency], description: 'Clean Torrents' do\n  trash(dir('~/Downloads/*.torrent'))\nend\n```\n\n## Warranty\n\nTHERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING\nTHE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR\nIMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\nTHE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU\nASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n## License\n\nGPLv2.  See LICENSE for a copy.\n\n  [documentation]: https://www.rubydoc.info/github/maid/maid/master\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaid%2Fmaid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaid%2Fmaid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaid%2Fmaid/lists"}