Skip to content

Instantly share code, notes, and snippets.

@shigeya
Created February 14, 2014 01:36
Show Gist options
  • Save shigeya/8994275 to your computer and use it in GitHub Desktop.
Save shigeya/8994275 to your computer and use it in GitHub Desktop.
#!/usr/pkg/bin/ruby
#puts 'require "fileinto";'
if ARGV[0] =~ /^\+(.*)/
folder = $1
ARGV.shift
else
folder = "INBOX.01.000Informative";
end
header = "from"
doif = "elsif"
a = Array.new
ARGF.each {|p|
p.chomp!
p.sub!(/^\s+/, "")
p.sub!(/#.*/, "")
if p != "" then
a.push(p)
end
}
puts "#{doif} anyof("+ a.collect {|i| "header :contains [\"#{header}\"] [\"#{i}\"]"}.join(",\n ") + " ) {"
puts " fileinto \"#{folder}\";"
puts "}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment