converting mpost(ed) files individually to eps
Antonio Olivares
olivares14031 at gmail.com
Tue Jun 19 02:00:04 UTC 2012
On Mon, Jun 18, 2012 at 8:30 PM, Robert Bonomi <bonomi at mail.r-bonomi.com> wrote:
>> > Date: Mon, 18 Jun 2012 19:50:01 -0500
>> > From: Antonio Olivares <olivares14031 at gmail.com>
>> > Subject: converting mpost(ed) files individually to eps
>> >
>> > 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.
>>
>> Correct. The script you showd processes a _single_ argument only.
>> Use a 'for loop' to handle multiple files, something like --
>> for thisfile in file.* do
>> `mpost-eps $thisfile
>> end
>>
>> >
>> > [[ sneck -- copy of script itself ]]
>> >
>> > 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
>>
>> You were *close*. what you wanted is (assuming MPOST and GS are defined:
>> for file in {{list or wildcard}} do
>> $MPOST $file
>> $GS -dNOPAUSE -dBATCH -sDEVICE=epswrite -sOutputFile=$file.eps $file.1
>> end
>
> I may have understood. if it is MPOST that is producing the multiple files,
> then you want:
> $MPOST
> for file in file.* do
> $GS -dNOPAUSE -dBATCH -sDEVICE=epswrite -sOutputFile=$file.eps $file
> end
>
> This will produce a series of files named file.1.eps, file.2.eps, etc.
I added this to the script:
$MPOST $1.mp
for file in file.* do
$GS -dNOPAUSE -dBATCH -sDEVICE=epswrite -sOutputFile=$file.eps $file
end
But I get error in line 16:
$ ./mpost-eps webfig
./mpost-eps: 16: Syntax error: word unexpected
File follows here: mpost-eps:
=======================
$ cat mpost-eps
#!/bin/sh
MPOST=/usr/bin/kertex/mpost
GS=/usr/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
for file in file.* do
$GS -dNOPAUSE -dBATCH -sDEVICE=epswrite -sOutputFile=$file.eps $file
end
#$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
=======================
It would probably be better if insead of
file.1.eps, file.2.eps, file.3.eps , ... , fileN.eps to write to
file-1.eps, file-2.eps, file-3.eps, ..., file-N.eps.
Some friends tell me that the file generated by metapost is already an
eps file, that I am only making things difficult :(
Thanks for your help & suggestions.
Regards,
Antonio
More information about the freebsd-questions
mailing list