#!/usr/bin/ruby require "tmpdir" require "fileutils" require "kconv" print "Please give me the path of the winmail.dat file: " a = STDIN.gets if a[0, 1] == "~" a[0, 1] = ENV["HOME"] end a.gsub!("\\", "") a.strip! Dir.mktmpdir { |dir| FileUtils.copy_file(a, "#{dir}/winmail.dat") d = File.dirname(a) b = File.basename(a, ".*") if FileTest.exist?("#{d}/#{b}") n = 1 while FileTest.exist?("#{d}/#{b}_#{n}") n += 1 end b = "#{b}_#{n}" end Dir.chdir(dir) system("tnef