#! /usr/bin/env ruby require 'getoptlong' if ARGV.empty? puts "Usage: find-inactive-ml [-d num] ..." exit 0 end ndays = 100 parser = GetoptLong.new parser.set_options(['--days', '-d', GetoptLong::REQUIRED_ARGUMENT]) parser.each_option {|name, arg| if name == "--days" ndays = arg.to_i end } now = Time.now ARGV.each {|dir| last = Time.at(0) Dir.new(dir).each {|file| fullpath = File.join(dir, file) next unless File.file?(fullpath) last = [last, File.mtime(fullpath)].max } if (now - last) > 86400 * ndays # no mail received for last n days puts dir end }