Skip to content

Instantly share code, notes, and snippets.

@jiphex
Created September 25, 2013 13:14
Show Gist options
  • Save jiphex/6699405 to your computer and use it in GitHub Desktop.
Save jiphex/6699405 to your computer and use it in GitHub Desktop.
Mark all mail (and maildirs, recursively) as read within the given Maildir. Requires the 'maildir' gem.
#!/usr/bin/env ruby
require 'maildir'
class Maildir
def subdirectories
dirs = Dir.glob(File.join(@path,"*")).find_all{|a|File.directory?(a)}
dirs.map{|a|Maildir.new(a)}
end
def read_all!
self.list(:new).each{|l|l.process}
self.list(:cur).each{|m|m.seen!}
end
end
START_DIR="~/Maildir"
md = Maildir.new(START_DIR)
md.read_all!
md.subdirectories.each do |s|
s.read_all!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment