Created
June 15, 2012 16:48
-
-
Save clicube/2937526 to your computer and use it in GitHub Desktop.
make eps and tex file using gnuplot automater script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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