Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#!/usr/bin/env lua5.1
-- This file:
--   http://anggtwu.net/LUA/QPDFMerge.lua.html
--   http://anggtwu.net/LUA/QPDFMerge.lua
--          (find-angg "LUA/QPDFMerge.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- (defun e () (interactive) (find-angg "LUA/QPDFMerge.lua"))
--
-- See: https://github.com/qpdf/qpdf/issues/11#issuecomment-18768487
--      qpdf --empty --pages $(for i in a*.pdf; do echo $i 1-z; done) -- b.pdf
--      (find-es "ps" "qpdf-merge")
--
-- «.update-all»	(to "update-all")


MTable = Class {
  type = "MTable",
  from = function (stem)
       return MTable.getincls(stem.."-tudo.tex")
              :map("%s.pdf")
              :map("%s 1-z")
              :postoutput(stem)
              :pretitle(stem)
              :precmd()
     end,
  getincls = function (fname) return MTable.getincls0(ee_readfile(fname)) end,
  getincls0 = function (bigstr)
      local pat = "\n\\incl{(.-)}"
      local m = MTable {}
      for stem in bigstr:gmatch(pat) do table.insert(m, stem) end
      return m
    end,
  __tostring = function (o) return o:tostring("\n") end,
  __index = {
    tostring = function (o, sep)
        return table.concat(o, sep or "\n")
      end,
    map = function (o, f)
        if type(f) == "string" then
          local fmt = f
          f = function (s) return format(fmt, s) end
        end
        return MTable(map(f, o))
      end,
    pre  = function (m, s) table.insert(m, 1, s); return m end,
    post = function (m, s) table.insert(m,    s); return m end,
    pretitle   = function (m, stem) return m:pre(stem.."-tudo.pdf 1-1") end,
    precmd     = function (m, stem) return m:pre("qpdf --empty --pages") end,
    postoutput = function (m, stem) return m:post("-- "..stem.."-Tudo.pdf") end,
  },
}

-- (find-es "lua5" "run_options")
-- (find-angg "LUA/GetOpt1.lua" "GetOpt")
--
run_stem = function (stem)
    local cmd0 = MTable.from(stem)
    local cmd  = cmd0:tostring" "
    print(cmd)
    print(getoutput(cmd))
  end

run_options = function (a, b)
    if     a == nil         then return
    elseif a == "QPDFMerge" then return
    elseif a == "-stem"     then run_stem(b)
    else PP("Bad options:", a, b)
    end
  end

run_options(...)


--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "QPDFMerge.lua"
chdir "~/LATEX/"

m = MTable.from "2023-1-C2"
= m
= m:tostring" "
= getoutput(m:tostring" ")
run_options("-stem", "2023-1-C2")

--]]


-- «update-all»  (to ".update-all")
--[[
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd ~/LATEX/
A=(
    2019-1-C2 2019-1-C3
    2019-2-C2 2019-2-C3
    2020-1-C2 2020-1-C3
    2020-2-C2 2020-2-C3
    2021-1-C2 2021-1-C3
    2021-2-C2 2021-2-C3
    2022-1-C2 2022-1-C3
    2022-2-C2 2022-2-C3
    2023-1-C2           2023-1-C4 2023-1-ES
    2023-2-C2 2023-2-C3
)
A=(
    2024-1-C2 2024-1-C3
  )
for i in $A; do echo ${i}-Tudo.pdf; done | tee /tmp/o
for i in $A; do ~/LUA/QPDFMerge.lua -stem $i; done
for i in $(cat /tmp/o); do echo http://anggtwu.net/LATEX/${i}; done

cd ~/LATEX/
cat /tmp/o
rsync -avvz -e ssh $(cat /tmp/o) $LINP/LATEX/
rsync -avvz -e ssh $(cat /tmp/o) $LINS/LATEX/

--]]






-- Local Variables:
-- coding:  utf-8-unix
-- End: