From owner-freebsd-questions@FreeBSD.ORG Tue Jun 19 02:00:04 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AC114106566C for ; Tue, 19 Jun 2012 02:00:04 +0000 (UTC) (envelope-from olivares14031@gmail.com) Received: from mail-gh0-f182.google.com (mail-gh0-f182.google.com [209.85.160.182]) by mx1.freebsd.org (Postfix) with ESMTP id 57F1A8FC0A for ; Tue, 19 Jun 2012 02:00:04 +0000 (UTC) Received: by ghbz22 with SMTP id z22so4900517ghb.13 for ; Mon, 18 Jun 2012 19:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=YFO+SJiI+y2jJzgGweRi0slTzg+MocBzVV8x83Awd1k=; b=ZM1DxkF91eW66DiOAKV+mECGXZN/SyNziGBQX+pwKpGOuqp6+XS76arCU11fW/pv4g SS2YcFJqxBaHYHLIM/KohJ+7r3WVpJfZR1fUtcz30l5JXhDbbO3Zeuy5xVUj251WAcB6 48ALhAF0AS3RfTNaZMap/QMxe1wtYbf4QBpDo9Kgo3IVbwayCw8K4DSCl5NX4077IHUN 92lITF6JJd/mVJGrf2J+/2vKiJnzWrBF90i49B9ha/tgOh5fHfVEMjqnB73GrYrKYvqS dRXxOIiBBBW6wRl1KomER4j20LOsYJKaqpdX/Rk57S2Pj/bW/LSLaj5gkC4o7Ear+aAd weJw== MIME-Version: 1.0 Received: by 10.50.173.5 with SMTP id bg5mr2303294igc.35.1340071203553; Mon, 18 Jun 2012 19:00:03 -0700 (PDT) Received: by 10.50.112.4 with HTTP; Mon, 18 Jun 2012 19:00:03 -0700 (PDT) In-Reply-To: <201206190130.q5J1UQ1C015381@mail.r-bonomi.com> References: <201206190110.q5J1AorD015312@mail.r-bonomi.com> <201206190130.q5J1UQ1C015381@mail.r-bonomi.com> Date: Mon, 18 Jun 2012 21:00:03 -0500 Message-ID: From: Antonio Olivares To: Robert Bonomi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-questions@freebsd.org Subject: Re: converting mpost(ed) files individually to eps X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 02:00:04 -0000 On Mon, Jun 18, 2012 at 8:30 PM, Robert Bonomi w= rote: >> > Date: Mon, 18 Jun 2012 19:50:01 -0500 >> > From: Antonio Olivares >> > Subject: converting mpost(ed) files individually to eps >> > >> > Dear folks, >> > >> > I am taking a plunge to learning a little bit of metapost. =A0I 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. =A0The script you showd processes a _single_ argument only. >> Use a 'for loop' to handle multiple files, something like =A0-- >> =A0 =A0for thisfile in file.* do >> =A0 =A0 `mpost-eps $thisfile >> =A0 =A0end >> >> > >> > [[ sneck -- copy of script itself ]] >> > >> > I run the script >> > $ ./mpost-eps file >> > without *.mp extension. =A0but only one gets converted. =A0I don't kno= w >> > enough shell programming to do something like >> > for i in file.i do >> > $GS -dNOPAUSE -dBATCH -sDEVICE=3Depswrite -sOutputFile=3D$1.eps $1.i >> >> You were *close*. =A0what you wanted is (assuming MPOST and GS are defin= ed: >> =A0 for file in {{list or wildcard}} do >> =A0 =A0$MPOST $file >> =A0 =A0$GS -dNOPAUSE -dBATCH -sDEVICE=3Depswrite -sOutputFile=3D$file.ep= s $file.1 >> =A0 end > > I may have understood. =A0if it is MPOST that is producing the multiple f= iles, > then you want: > =A0 $MPOST > =A0 for file in file.* =A0do > =A0 =A0$GS -dNOPAUSE -dBATCH -sDEVICE=3Depswrite -sOutputFile=3D$file.eps= $file > =A0 end > > This will produce a series of files named =A0file.1.eps, file.2.eps, etc. I added this to the script: $MPOST $1.mp for file in file.* do $GS -dNOPAUSE -dBATCH -sDEVICE=3Depswrite -sOutputFile=3D$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: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D $ cat mpost-eps #!/bin/sh MPOST=3D/usr/bin/kertex/mpost GS=3D/usr/bin/gs ERROR=3D"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=3Depswrite -sOutputFile=3D$file.eps $file end #$MPOST $1.mp #$GS -dNOPAUSE -dBATCH -sDEVICE=3Depswrite -sOutputFile=3D$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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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