Skip to content

Instantly share code, notes, and snippets.

@clicube
Created June 15, 2012 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clicube/2937526 to your computer and use it in GitHub Desktop.
Save clicube/2937526 to your computer and use it in GitHub Desktop.
make eps and tex file using gnuplot automater script
#! /usr/bin/ruby
BaseDir = File::expand_path(File::dirname(__FILE__))
Dir.chdir(BaseDir)
Files = Dir::glob("**/*.plot")
Files.each do |fpplot|
puts fpplot
target_dir = File::dirname(fpplot)
fnplot = File::basename(fpplot)
fnbase = File::basename(fnplot,".plot")
fpbase = target_dir + "/" + fnbase
fpeps = fpbase + ".eps"
fptex = fpbase + ".tex"
Dir.chdir target_dir
cmd = "gnuplot #{fnplot}"
$stdout.write `#{cmd}`
Dir.chdir BaseDir
buf = File.read(fptex).gsub("\\includegraphics{#{fnbase}}","\\includegraphics{#{fpbase}}")
File.open(fptex,"w") do |f|
f.write buf
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment