require 'path' Path.dir.glob("**/*.dot") do |path| cmd = "dot -Tgif -o #{path.sub_ext('.gif')} #{path}" puts cmd `#{cmd}` end