From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/95340 Path: news.gmane.org!not-for-mail From: Keith McKay Newsgroups: gmane.comp.tex.context Subject: Re: Iterate through a directory Date: Mon, 4 Jul 2016 19:26:27 +0100 Organization: The PotHole Press Message-ID: References: <24117c14-e8b0-3bbf-6122-342303400e0c@gmail.com> <189e2309-5429-0754-f0f9-5e31f4877dad@wxs.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3604466421002415577==" X-Trace: ger.gmane.org 1467656830 12597 80.91.229.3 (4 Jul 2016 18:27:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 4 Jul 2016 18:27:10 +0000 (UTC) To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Mon Jul 04 20:26:57 2016 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bK8a9-0008IC-3c for gctc-ntg-context-518@m.gmane.org; Mon, 04 Jul 2016 20:26:57 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 7591810E96; Mon, 4 Jul 2016 20:26:44 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j6LicL-ewp-q; Mon, 4 Jul 2016 20:26:43 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [IPv6:::1]) by zapf.ntg.nl (Postfix) with ESMTP id BF1FE10E98; Mon, 4 Jul 2016 20:26:43 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id B10EF10E95 for ; Mon, 4 Jul 2016 20:26:42 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Jfr_2Wn4qQMR for ; Mon, 4 Jul 2016 20:26:41 +0200 (CEST) Original-Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id E224B10E93 for ; Mon, 4 Jul 2016 20:26:31 +0200 (CEST) Original-Received: by mail-wm0-f41.google.com with SMTP id z126so50596254wme.0 for ; Mon, 04 Jul 2016 11:26:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:organization:message-id:date:user-agent :mime-version:in-reply-to; bh=4a3zi0JE07mYooSmL3R5CalcxDPyDmhtuL+WmTKoIP4=; b=F51JNyLmfOUecvoMPXzRovALX3XsPDLTmMZdZ34HcsGFCY2Scfkd5QMGIUyTjdLsV4 fmhuFvEmbX5m2GcObVWcemWPJkAP7J+Ffzfx1tNvLdZml0GIm/PeDPMiJ/IMqVLyWI/g 3nogPC2r4rh0UjtF7n0hBZgHuZz4EZDmuMyybmNE4v7gzv5sAm3gC100RaSHOP4kM4cS L0rNJULkPJkEl5Cg9LEFGfHrd1WY4j1Do8nUHeqjH/AzNT0WzWDvtaTvZv5OBSaOuHvY 963ZkPiNMMJQIlduCw4cBoqZYzdDSkXjGnGhUy/gmsq7v7ZMrJpPuZa5aLS8eyTVQ7JJ Lx4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to; bh=4a3zi0JE07mYooSmL3R5CalcxDPyDmhtuL+WmTKoIP4=; b=WWFphMSrDGhSaeiTBZrthfBYRWnsBHhlT3MiDRqrrrYvKKcRhULdLsY9pu5397JI9S tC29xW0fmX/yVJVNRyMwCUrOhvby30dyHiU1aFxjLwMPu9WkQAZb8iNucZZhF7ELT6VC wTYAXUrDLLasAylpuzoJUCkGF8OBP4WEZZzFEKjme0w7Qj37ZSn4YV3rCYDOyfPQa8ke ek3Jsw/LBIFIcCTo99egLvbe1kLVxORljT2mGoHUBI41l3zR7V+rkk0oPnr6nWNxCycD JVTfIlupxS7T8Bbo8SBxhIfP3pM0BxaFU78tUMkA4jWMxa6aOnfmgE+XVlyIvmxc9QMB K3zQ== X-Gm-Message-State: ALyK8tI+l3aFAeLJe/Fu8f09Vytv6vyOFUzOZaeNUiOCZvZNs9CeXGfIrhXWl4MajnvsNw== X-Received: by 10.194.246.70 with SMTP id xu6mr11264978wjc.124.1467656791270; Mon, 04 Jul 2016 11:26:31 -0700 (PDT) Original-Received: from Keiths-Mac-mini.local (cpc100348-uddi28-2-0-cust7.20-3.cable.virginm.net. [82.41.64.8]) by smtp.googlemail.com with ESMTPSA id h8sm1723118wjg.9.2016.07.04.11.26.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jul 2016 11:26:30 -0700 (PDT) User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 In-Reply-To: <189e2309-5429-0754-f0f9-5e31f4877dad@wxs.nl> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.16 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.org gmane.comp.tex.context:95340 Archived-At: This is a multi-part message in MIME format. --===============3604466421002415577== Content-Type: multipart/alternative; boundary="------------AD138016340D1B6E4445C322" This is a multi-part message in MIME format. --------------AD138016340D1B6E4445C322 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Thanks Hans I'll give it a try. Best Wishes Keith On 04/07/2016 17:30, Hans Hagen wrote: > On 7/4/2016 5:52 PM, Keith McKay wrote: >> Colleagues >> >> I'm preparing a booklet of figures which are stored in a directory, >> however their is no structure in their naming. I could go through them >> all and rename them along the lines of Pict1.jpg, Pict2.jpg etc and >> \dostepwiserecurse as in the example below >> >> >> \setupexternalfigures [directory={/a/directory}] >> \starttext >> \dostepwiserecurse{1}{10}{1} >> { >> \externalfigure[Pict\recurselevel.jpg] >> } >> \stoptext >> >> However, I was wondering if was possible to iterate through the >> directory using a wildcard and have something like >> >> \externalfigure[*.jpg} >> >> to make it generic, or would I have to use lua. > > \startluacode > > for _, name in ipairs(dir.glob("*.jpg")) do > context.externalfigure { name } > end > > \stopluacode > > ----------------------------------------------------------------- > Hans Hagen | PRAGMA ADE > Ridderstraat 27 | 8061 GH Hasselt | The Netherlands > tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl > ----------------------------------------------------------------- > ___________________________________________________________________________________ > > If your question is of interest to others as well, please add an entry > to the Wiki! > > maillist : ntg-context@ntg.nl / > http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > ___________________________________________________________________________________ --------------AD138016340D1B6E4445C322 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

Thanks Hans I'll give it a try.

Best Wishes

Keith


On 04/07/2016 17:30, Hans Hagen wrote:=
On 7/4/2016 5:52 PM, Keith McKay wrote:
Colle= agues

I'm preparing a booklet of figures which are stored in a directory,
however their is no structure in their naming.=C2=A0 I could go through them
all and rename them along the lines of Pict1.jpg, Pict2.jpg etc and
\dostepwiserecurse as in the example below


\setupexternalfigures [directory=3D{/a/directory}]
\starttext
\dostepwiserecurse{1}{10}{1}
{
\externalfigure[Pict\recurselevel.jpg]
}
=C2=A0\stoptext

However, I was wondering if was possible to iterate through the
directory using a wildcard and have something like

\externalfigure[*.jpg}

to make it generic, or would I have to use lua.

\startluacode

for _, name in ipairs(dir.glob("*.jpg")) do
=C2=A0=C2=A0=C2=A0 context.externalfigure { name }
end

\stopluacode

-----------------------------------------------------------------
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 Hans Hagen | PRAGMA ADE
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tel: 038 477 53 69 | www.pragma-a= de.nl | www.pragma-pod.nl
-----------------------------------------------------------------
_________________________________________________________________________= __________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage=C2=A0 :
http://www.pragma-ade.nl / http://tex.aanhet.net
archive=C2=A0 : http://foundry.supelec.fr/project= s/contextrev/
wiki=C2=A0=C2=A0=C2=A0=C2=A0 : http://contextgarden.net
_________________________________________________________________________= __________


--------------AD138016340D1B6E4445C322-- --===============3604466421002415577== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly90ZXguYWFuaGV0Lm5ldAphcmNoaXZlICA6IGh0dHA6Ly9mb3VuZHJ5LnN1cGVsZWMu ZnIvcHJvamVjdHMvY29udGV4dHJldi8Kd2lraSAgICAgOiBodHRwOi8vY29udGV4dGdhcmRlbi5u ZXQKX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX18= --===============3604466421002415577==--