Skip to main content

Benjamin Oakes

Photo of Ben Oakes

Hi, I'm Ben Oakes and this is my geek blog. Currently, I'm a Ruby/JavaScript Developer at Liaison. Previously, I was a Developer at Continuity and Hedgeye, a Research Assistant in the Early Social Cognition Lab at Yale University and a student at the University of Iowa. I also organize, ICRuby, OpenHack Iowa City, and previously organized NewHaven.rb. I have an amazing wife named Danielle Oakes.

Filtering for the Maid category. Clear

Keep your machine clean in the New Year with Maid v0.6.0

by Ben

Happy New Year!

We just released Maid v0.6.0, which is full of new features:

As you can see, the Maid community has a lot to do with Maid’s continued development. Thank you everyone for your contributions!

Maid remains a popular open source project. (Check out others on my GitHub.) It was downloaded by users over 7000 times and starred over 300 times just in 2014, for a total of 16684 downloads and 1045 stars. Our community of users sharing rules now has 42 examples for you to consider when scripting your own Maid.

Let’s look at a few of the ways Maid helps you with its new features.

Watch rules

In the past, Maid has been run manually or via cron. Maid v0.6.0 introduces support for watching your filesystem for changes and taking action immediately. (Under the hood, this is implemented with the listen gem, which uses fsevent on OSX and inotify on Linux.)

Starting Maid automatically at login is pretty straitforward on my daily driver (Ubuntu) — see the README for details. It isn’t quite as easy on OSX — a situation I expect will improve — but in the meantime, check out Jurriaan’s great post on running Maid as a Daemon on OS X.

This new “watch” feature opens up all sorts of possibilities. Since Maid can now act automatically, you can even treat folders as drop targets for your Maid rules.

Maid.rules do
  # Drop files in this directory and watch the duplicates disappear...
  watch '~/Desktop/De-dupe' do
    rule 'trash dupes' do
      trash verbose_dupes_in('~/Desktop/De-dupe/**/*')

  # Sift through a large collection of downloads by categorizing them as "image", "video", "text", etc.
  watch '~/Downloads' do
    rule 'categorize by media type' do
      files('~/Downloads/*').each do |path|
        move(path, mkdir("~/Downloads/#{media_type(path)}/"))

  # As your photos show up in your Dropbox, Maid will organize them for you!
  watch '~/Dropbox/Camera Uploads' do
    rule 'organize new photos by date' do
      where_content_type(files('~/Dropbox/Camera Uploads/*'), 'image').each do |path|
        iso8601 = modified_at(path).to_date.iso8601.sub('-', '/')
        move(path, mkdir("~/Dropbox/Albums/#{iso8601}/"))

We still support manual invocation and cron, but you should try watch — you’ll like it.

Image dimensions

Another handy addition is the ability to read the dimensions of images. Here’s an example:

# Keep your background pictures organized by their dimensions
watch '~/Pictures/Wallpaper' do
  rule 'organize wallpaper by dimensions' do
    where_content_type(dir('~/Pictures/Wallpaper/*'), 'image').each do |image|
      width, height = dimensions_px(image)
      move(image, mkdir("~/Pictures/Wallpaper/#{width}x#{height}"))

And since it’s Ruby, you can define your own logic, such as categorizing images as big/small or portrait/landscape.

Rake tasks

Once you know Maid, you might miss the methods it provides in your other Ruby projects, so Maid is now available as a Rake task as well. As an example, look no further than Maid’s own Rakefile:

require 'maid' do
  # Clean up Rubinius-compilied Ruby

  # Get rid of generated files

All Maid tools are available to you in Rake tasks, so you can do any common file manipulations you need.

That’s all for now. I hope Maid can help you keep your computer tidy in 2015!

Maid v0.4-series update

by Ben

After the OS X 10.9 release, I got some energy to release Maid v0.4.0, mostly because it finally made it possible to drop Ruby 1.8.7 compatibility while still letting casual Ruby users on OS X use Maid.  Needless to say, I’m happy OS X 10.9 has Ruby 2.0 included.  I had honestly gotten stuck on Ruby 1.8.7 compatibility, since so many gems have been dropping support.  It is officially end-of-life, after all.

In case you missed it, here’s some details from the ChangeLog:

I’ve also made a few “patch” releases, after being notified of new dependency versions and testing their compatibility.

If you’re just getting started with Maid, the README is the best place to start looking.  Enjoy!

Maid v0.3.0 release!

by Ben

I released Maid v0.3.0 yesterday, after using Maid v0.3.0 Beta 1 for over a week myself. It was also downloaded 36 times, without any known bugs reported by beta test team.

From the change log:

I did have to make some expected changes from move to rename, however, but the warning messages for that show the new usage pretty clearly:

skipping move because foo is not a directory (use 'mkdir' to create first, or use 'rename')

Otherwise, work is progressing on the next version of Maid also. Hopefully there will be another beta soon.

But in the meantime, Maid v0.3.0 has already been downloaded 62 times. If you haven’t already given it a try, maybe Maid can help you with your spring cleaning… :)


Maid v0.3.0 Beta

by Ben

I’ve released a beta of Maid v0.3.0. It contains a bugfix which required an additional DSL method to be added. The move method now only moves to pre-existing directories, and the new rename method should be used if renaming is the intention. This makes it easier to detect accidental overwrites.

From my observations, most of the time users who share their rules are using move with directories, so it should be a pretty painless upgrade… but since there’s a new method in the DSL, this new version is called v0.3.0 instead of v0.2.3. (A new version v0.4.0 is in the works — it was once referred to as v0.3.0 — so don’t let that confuse you. :) )

To install:

gem install maid --pre

I’m interested in whether anyone runs into issues with the change I described. Otherwise, it should be pretty much the same as v0.2.2. Please leave a comment in this issue with your experiences!

For more information, see the ChangeLog or RubyGems.