# [texhax] list files with lua: windows vs linux

aldus 85 pc_dell2 at outlook.fr
Fri Apr 8 20:26:29 CEST 2016

Hi !

I remember having read (and experienced) that we could know about the order in which the for iterator would take things.
May be a bypass would consist in sorting the list retrieved from the OS.
May be a lua forum would more adequate to place the question.

Hope this helps.

Aldus
(mobile)

Aldus
(mobile)
> Le 8 avr. 2016 à 15:23, Arno Trautmann <Arno.Trautmann at gmx.de> a écrit :
>
> Hi all,
>
> I have a data evaluation script that produces eps output files named like
>
> scan043_shot001...
> scan043_shot002...
> scan043_shot003...
>
> I want to have them nicely put together in one pdf, including some additional information. Using some Lua code, I managed to get exactly what I wanted. Under Windows, at least – using:
>
> for file in lfs.dir(".") do
>
> This results in an iterator that lists the files numerically. Under Linux, however, the file listing is completely arbitrary. Is there a way to influence the order of the output of lfs.dir? The full example is listed below.
> Is there a (maybe even more elegant) way to get this reliably listing the files independently of the OS?
>
> I would be very thankful for any hints!
>
> Best,
> Arno
>
> \documentclass{beamer}
> \usepackage{graphicx,luacode}
> \begin{document}
> \catcode\_12
> \begin{luacode}
> require "lfs"
> for file in lfs.dir(".") do
> texio.write_nl(file)
> if string.find(file,string.sub(tex.jobname,-7)) then
> if string.find(file,".eps") then
> if string.find(file,".pdf") then else
> tex.print("\\begin{frame}{"..file.."}\\includegraphics{{{"..string.sub(file,1,-5).."}}}\\end{frame}")
> end
> end
> end
> end
> \end{luacode}
>
> \end{document}
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/
`