converting mpost(ed) files individually to eps

Antonio Olivares olivares14031 at gmail.com
Tue Jun 19 00:50:02 UTC 2012


Dear folks,

I am taking a plunge to learning a little bit of metapost.  I have
found examples page using google.

http://www.tlhiv.org/MetaPost/examples/examples.html

I want to convert output files individually to eps.

I can only convert the first one output say file.1 to file.eps, but
when there are more files, ie, file.2, ..., file.10, all the files
between .2 and .10 do not get converted/saved to *.eps extension.

script called mpost-eps below:

===========================================================
$ cat mpost-eps
#!/bin/sh

MPOST=/usr/local/bin/kertex/mpost
GS=/usr/local/bin/gs

ERROR="Too few arguments : no file name specified"
[ $# -eq 0 ] && echo $ERROR && exit # no args? ... print error and exit

# check that the file exists
if [ -f $1.mp ]
then
# if it exists then metapost it,then convert with ghostscript, then
remove all the unneeded files
$MPOST $1.mp
$GS -dNOPAUSE -dBATCH -sDEVICE=epswrite -sOutputFile=$1.eps $1.1

# these lines can be appended to delete other files, such as *.out
if [ -f $1.log ]
then
	rm *.log
fi
else
# otherwise give this output line with a list of available metapost files
echo the file doesnt exist butthead! Choose one of these:
ls *.mp
fi
===========================================================

I run the script
$ ./mpost-eps file
without *.mp extension.  but only one gets converted.  I don't know
enough shell programming to do something like
for i in file.i do
$GS -dNOPAUSE -dBATCH -sDEVICE=epswrite -sOutputFile=$1.eps $1.i

but it does not work correctly.  I can change the mpost
executable[using kertex by T. Laronde
(http://www.kergis.com/en/kertex.html) ] at will as I also have
texlive installed by FreeBSD TeXLive Ports by Roman
Tartiere(https://code.google.com/p/freebsd-texlive/) ,
/usr/local/bin/mpost is the executable there, or same one but in
metapost executable by default teTeX.

Is there a magical incantanation I can use to output all the files to
eps and include them in documents either \TeX{}ed or \LaTeX{}ed?

Thanks in Advance,


Antonio


More information about the freebsd-questions mailing list