Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
-- This file:
--   http://anggtwu.net/LUA/LogsPdfizados1.lua.html
--   http://anggtwu.net/LUA/LogsPdfizados1.lua
--          (find-angg "LUA/LogsPdfizados1.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- (defun e () (interactive) (find-angg "LUA/LogsPdfizados1.lua"))
-- (find-es "ead" "logs-pdfizados")

-- «.pdfs»		(to "pdfs")
-- «.PdfName»		(to "PdfName")
-- «.Marked»		(to "Marked")
-- «.find-arounds»	(to "find-arounds")

-- «pdfs»  (to ".pdfs")
pdfs = [[
2020.1-C2/C2-C1-RCN-PURO-2020.1-2.pdf
2020.1-C2/C2-C1-RCN-PURO-2020.1-3.pdf
2020.1-C2/C2-C1-RCN-PURO-2020.1.pdf
2020.1-C2/C2-E1-RCN-PURO-2020.1-2.pdf
2020.1-C2/C2-E1-RCN-PURO-2020.1-3.pdf
2020.1-C2/C2-E1-RCN-PURO-2020.1.pdf
2020.1-C3/C3-M1-RCN-PURO-2020.1-2.pdf
2020.1-C3/C3-M1-RCN-PURO-2020.1-3.pdf
2020.1-C3/C3-M1-RCN-PURO-2020.1-4.pdf
2020.1-C3/C3-M1-RCN-PURO-2020.1.pdf
2020.2-C2/C2-C1-RCN-PURO-2020.2-2.pdf
2020.2-C2/C2-C1-RCN-PURO-2020.2.pdf
2020.2-C2/C2-E1-RCN-PURO-2020.2-2.pdf
2020.2-C2/C2-E1-RCN-PURO-2020.2-3.pdf
2020.2-C2/C2-E1-RCN-PURO-2020.2.pdf
2020.2-C3/C3-M1-RCN-PURO-2020.2-2.pdf
2020.2-C3/C3-M1-RCN-PURO-2020.2.pdf
2021.1-C2/C2-C1-RCN-PURO-2021.1-2.pdf
2021.1-C2/C2-C1-RCN-PURO-2021.1-3.pdf
2021.1-C2/C2-C1-RCN-PURO-2021.1.pdf
2021.1-C2/C2-E1-RCN-PURO-2021.1-2.pdf
2021.1-C2/C2-E1-RCN-PURO-2021.1-3.pdf
2021.1-C2/C2-E1-RCN-PURO-2021.1-4.pdf
2021.1-C2/C2-E1-RCN-PURO-2021.1-5.pdf
2021.1-C2/C2-E1-RCN-PURO-2021.1.pdf
2021.1-C3/C3-M1-RCN-PURO-2021.1-2.pdf
2021.1-C3/C3-M1-RCN-PURO-2021.1.pdf
2021.2-C2/C2-C1-RCN-PURO-2021.2-2.pdf
2021.2-C2/C2-C1-RCN-PURO-2021.2.pdf
2021.2-C2/C2-E1-RCN-PURO-2021.2-2.pdf
2021.2-C2/C2-E1-RCN-PURO-2021.2-3.pdf
2021.2-C2/C2-E1-RCN-PURO-2021.2.pdf
2021.2-C3/C3-M1-RCN-PURO-2021.2-2.pdf
2021.2-C3/C3-M1-RCN-PURO-2021.2-3.pdf
2021.2-C3/C3-M1-RCN-PURO-2021.2-4.pdf
2021.2-C3/C3-M1-RCN-PURO-2021.2.pdf
]]

yys_to_letter = {
  ["201"] = "a",
  ["202"] = "b",
  ["211"] = "c",
  ["212"] = "d",
}

-- «PdfName»  (to ".PdfName")
PdfName = Class {
  type  = "PdfName",
  parse = function (fname)
      local fmt = "20(..).(.)%-C(.)/...(.).................(.*)"
      local yy,s,m,t,rest = fname:match(fmt)
      local n0 = rest:match("[0-9]")
      local n = n0 or "1"
      return yy,s,m,t,rest,n0,n
    end,
  from = function (fname)
      local yy,s,m,t,rest,n0,n = PdfName.parse(fname)
      return PdfName {fname=fname, yy=yy, s=s, m=m, t=t, n=n}
    end,
  __tostring = function (pn)
      return pn:short() .. ": " .. pn.fname
    end,
  __index = {
    letter = function (pn)
        return yys_to_letter[pn.yy .. pn.s]
      end,
    short1 = function (pn)
        local letter = pn:letter()
        local Turma  = pn.t
        local turma  = Turma:lower()
        return pn.m .. letter .. turma .. pn.n
      end,
    short = function (pn)
        local fmt = "20%s.%s-C%s-%s1-%s"
        return format(fmt, pn.yy, pn.s, pn.m, pn.t, pn.n)
      end,
    cp = function (pn, dir)
        local fmt = "cp -v ~/%-40s %s%s.pdf"
        return format(fmt, pn.fname, dir or "", pn:short())
      end,
  },
}


--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "LogsPdfizados1.lua"
for li in pdfs:gmatch("([!-~]+)") do
  pn = PdfName.from(li)
  -- print(pn)
  print(pn:cp("/tmp/quarentena/"))
end

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-fline "/tmp/quarentena/")
rm -Rv /tmp/quarentena/
mkdir  /tmp/quarentena/
cd     /tmp/quarentena/
cp -v ~/2020.1-C2/C2-C1-RCN-PURO-2020.1-2.pdf    /tmp/quarentena/2ac2.pdf
cp -v ~/2020.1-C2/C2-C1-RCN-PURO-2020.1-3.pdf    /tmp/quarentena/2ac3.pdf
cp -v ~/2020.1-C2/C2-C1-RCN-PURO-2020.1.pdf      /tmp/quarentena/2ac1.pdf
cp -v ~/2020.1-C2/C2-E1-RCN-PURO-2020.1-2.pdf    /tmp/quarentena/2ae2.pdf
cp -v ~/2020.1-C2/C2-E1-RCN-PURO-2020.1-3.pdf    /tmp/quarentena/2ae3.pdf
cp -v ~/2020.1-C2/C2-E1-RCN-PURO-2020.1.pdf      /tmp/quarentena/2ae1.pdf
cp -v ~/2020.1-C3/C3-M1-RCN-PURO-2020.1-2.pdf    /tmp/quarentena/3am2.pdf
cp -v ~/2020.1-C3/C3-M1-RCN-PURO-2020.1-3.pdf    /tmp/quarentena/3am3.pdf
cp -v ~/2020.1-C3/C3-M1-RCN-PURO-2020.1-4.pdf    /tmp/quarentena/3am4.pdf
cp -v ~/2020.1-C3/C3-M1-RCN-PURO-2020.1.pdf      /tmp/quarentena/3am1.pdf
cp -v ~/2020.2-C2/C2-C1-RCN-PURO-2020.2-2.pdf    /tmp/quarentena/2bc2.pdf
cp -v ~/2020.2-C2/C2-C1-RCN-PURO-2020.2.pdf      /tmp/quarentena/2bc1.pdf
cp -v ~/2020.2-C2/C2-E1-RCN-PURO-2020.2-2.pdf    /tmp/quarentena/2be2.pdf
cp -v ~/2020.2-C2/C2-E1-RCN-PURO-2020.2-3.pdf    /tmp/quarentena/2be3.pdf
cp -v ~/2020.2-C2/C2-E1-RCN-PURO-2020.2.pdf      /tmp/quarentena/2be1.pdf
cp -v ~/2020.2-C3/C3-M1-RCN-PURO-2020.2-2.pdf    /tmp/quarentena/3bm2.pdf
cp -v ~/2020.2-C3/C3-M1-RCN-PURO-2020.2.pdf      /tmp/quarentena/3bm1.pdf
cp -v ~/2021.1-C2/C2-C1-RCN-PURO-2021.1-2.pdf    /tmp/quarentena/2cc2.pdf
cp -v ~/2021.1-C2/C2-C1-RCN-PURO-2021.1-3.pdf    /tmp/quarentena/2cc3.pdf
cp -v ~/2021.1-C2/C2-C1-RCN-PURO-2021.1.pdf      /tmp/quarentena/2cc1.pdf
cp -v ~/2021.1-C2/C2-E1-RCN-PURO-2021.1-2.pdf    /tmp/quarentena/2ce2.pdf
cp -v ~/2021.1-C2/C2-E1-RCN-PURO-2021.1-3.pdf    /tmp/quarentena/2ce3.pdf
cp -v ~/2021.1-C2/C2-E1-RCN-PURO-2021.1-4.pdf    /tmp/quarentena/2ce4.pdf
cp -v ~/2021.1-C2/C2-E1-RCN-PURO-2021.1-5.pdf    /tmp/quarentena/2ce5.pdf
cp -v ~/2021.1-C2/C2-E1-RCN-PURO-2021.1.pdf      /tmp/quarentena/2ce1.pdf
cp -v ~/2021.1-C3/C3-M1-RCN-PURO-2021.1-2.pdf    /tmp/quarentena/3cm2.pdf
cp -v ~/2021.1-C3/C3-M1-RCN-PURO-2021.1.pdf      /tmp/quarentena/3cm1.pdf
cp -v ~/2021.2-C2/C2-C1-RCN-PURO-2021.2-2.pdf    /tmp/quarentena/2dc2.pdf
cp -v ~/2021.2-C2/C2-C1-RCN-PURO-2021.2.pdf      /tmp/quarentena/2dc1.pdf
cp -v ~/2021.2-C2/C2-E1-RCN-PURO-2021.2-2.pdf    /tmp/quarentena/2de2.pdf
cp -v ~/2021.2-C2/C2-E1-RCN-PURO-2021.2-3.pdf    /tmp/quarentena/2de3.pdf
cp -v ~/2021.2-C2/C2-E1-RCN-PURO-2021.2.pdf      /tmp/quarentena/2de1.pdf
cp -v ~/2021.2-C3/C3-M1-RCN-PURO-2021.2-2.pdf    /tmp/quarentena/3dm2.pdf
cp -v ~/2021.2-C3/C3-M1-RCN-PURO-2021.2-3.pdf    /tmp/quarentena/3dm3.pdf
cp -v ~/2021.2-C3/C3-M1-RCN-PURO-2021.2-4.pdf    /tmp/quarentena/3dm4.pdf
cp -v ~/2021.2-C3/C3-M1-RCN-PURO-2021.2.pdf      /tmp/quarentena/3dm1.pdf

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-fline "/tmp/quarentena/")
rm -Rv /tmp/quarentena/
mkdir  /tmp/quarentena/
cd     /tmp/quarentena/
cp -v ~/2020.1-C2/C2-C1-RCN-PURO-2020.1-2.pdf    /tmp/quarentena/2020.1-C2-C1-2.pdf
cp -v ~/2020.1-C2/C2-C1-RCN-PURO-2020.1-3.pdf    /tmp/quarentena/2020.1-C2-C1-3.pdf
cp -v ~/2020.1-C2/C2-C1-RCN-PURO-2020.1.pdf      /tmp/quarentena/2020.1-C2-C1-1.pdf
cp -v ~/2020.1-C2/C2-E1-RCN-PURO-2020.1-2.pdf    /tmp/quarentena/2020.1-C2-E1-2.pdf
cp -v ~/2020.1-C2/C2-E1-RCN-PURO-2020.1-3.pdf    /tmp/quarentena/2020.1-C2-E1-3.pdf
cp -v ~/2020.1-C2/C2-E1-RCN-PURO-2020.1.pdf      /tmp/quarentena/2020.1-C2-E1-1.pdf
cp -v ~/2020.1-C3/C3-M1-RCN-PURO-2020.1-2.pdf    /tmp/quarentena/2020.1-C3-M1-2.pdf
cp -v ~/2020.1-C3/C3-M1-RCN-PURO-2020.1-3.pdf    /tmp/quarentena/2020.1-C3-M1-3.pdf
cp -v ~/2020.1-C3/C3-M1-RCN-PURO-2020.1-4.pdf    /tmp/quarentena/2020.1-C3-M1-4.pdf
cp -v ~/2020.1-C3/C3-M1-RCN-PURO-2020.1.pdf      /tmp/quarentena/2020.1-C3-M1-1.pdf
cp -v ~/2020.2-C2/C2-C1-RCN-PURO-2020.2-2.pdf    /tmp/quarentena/2020.2-C2-C1-2.pdf
cp -v ~/2020.2-C2/C2-C1-RCN-PURO-2020.2.pdf      /tmp/quarentena/2020.2-C2-C1-1.pdf
cp -v ~/2020.2-C2/C2-E1-RCN-PURO-2020.2-2.pdf    /tmp/quarentena/2020.2-C2-E1-2.pdf
cp -v ~/2020.2-C2/C2-E1-RCN-PURO-2020.2-3.pdf    /tmp/quarentena/2020.2-C2-E1-3.pdf
cp -v ~/2020.2-C2/C2-E1-RCN-PURO-2020.2.pdf      /tmp/quarentena/2020.2-C2-E1-1.pdf
cp -v ~/2020.2-C3/C3-M1-RCN-PURO-2020.2-2.pdf    /tmp/quarentena/2020.2-C3-M1-2.pdf
cp -v ~/2020.2-C3/C3-M1-RCN-PURO-2020.2.pdf      /tmp/quarentena/2020.2-C3-M1-1.pdf
cp -v ~/2021.1-C2/C2-C1-RCN-PURO-2021.1-2.pdf    /tmp/quarentena/2021.1-C2-C1-2.pdf
cp -v ~/2021.1-C2/C2-C1-RCN-PURO-2021.1-3.pdf    /tmp/quarentena/2021.1-C2-C1-3.pdf
cp -v ~/2021.1-C2/C2-C1-RCN-PURO-2021.1.pdf      /tmp/quarentena/2021.1-C2-C1-1.pdf
cp -v ~/2021.1-C2/C2-E1-RCN-PURO-2021.1-2.pdf    /tmp/quarentena/2021.1-C2-E1-2.pdf
cp -v ~/2021.1-C2/C2-E1-RCN-PURO-2021.1-3.pdf    /tmp/quarentena/2021.1-C2-E1-3.pdf
cp -v ~/2021.1-C2/C2-E1-RCN-PURO-2021.1-4.pdf    /tmp/quarentena/2021.1-C2-E1-4.pdf
cp -v ~/2021.1-C2/C2-E1-RCN-PURO-2021.1-5.pdf    /tmp/quarentena/2021.1-C2-E1-5.pdf
cp -v ~/2021.1-C2/C2-E1-RCN-PURO-2021.1.pdf      /tmp/quarentena/2021.1-C2-E1-1.pdf
cp -v ~/2021.1-C3/C3-M1-RCN-PURO-2021.1-2.pdf    /tmp/quarentena/2021.1-C3-M1-2.pdf
cp -v ~/2021.1-C3/C3-M1-RCN-PURO-2021.1.pdf      /tmp/quarentena/2021.1-C3-M1-1.pdf
cp -v ~/2021.2-C2/C2-C1-RCN-PURO-2021.2-2.pdf    /tmp/quarentena/2021.2-C2-C1-2.pdf
cp -v ~/2021.2-C2/C2-C1-RCN-PURO-2021.2.pdf      /tmp/quarentena/2021.2-C2-C1-1.pdf
cp -v ~/2021.2-C2/C2-E1-RCN-PURO-2021.2-2.pdf    /tmp/quarentena/2021.2-C2-E1-2.pdf
cp -v ~/2021.2-C2/C2-E1-RCN-PURO-2021.2-3.pdf    /tmp/quarentena/2021.2-C2-E1-3.pdf
cp -v ~/2021.2-C2/C2-E1-RCN-PURO-2021.2.pdf      /tmp/quarentena/2021.2-C2-E1-1.pdf
cp -v ~/2021.2-C3/C3-M1-RCN-PURO-2021.2-2.pdf    /tmp/quarentena/2021.2-C3-M1-2.pdf
cp -v ~/2021.2-C3/C3-M1-RCN-PURO-2021.2-3.pdf    /tmp/quarentena/2021.2-C3-M1-3.pdf
cp -v ~/2021.2-C3/C3-M1-RCN-PURO-2021.2-4.pdf    /tmp/quarentena/2021.2-C3-M1-4.pdf
cp -v ~/2021.2-C3/C3-M1-RCN-PURO-2021.2.pdf      /tmp/quarentena/2021.2-C3-M1-1.pdf

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-fline "/tmp/quarentena/")
cd     /tmp/quarentena/
for i in *.pdf; do echo $(basename $i .pdf); done
for i in *.pdf; do
  echo pdftotext -layout $i $(basename $i .pdf).txt
       pdftotext -layout $i $(basename $i .pdf).txt
done

# (defvar ee-pdftotext-program "pdftotext")
# (code-c-d "quarentena" "/tmp/quarentena/")
# (find-quarentenafile "")
# (setq last-kbd-macro (kbd "RET M-o <down>"))
# (find-quarentenagrep "grep --color=auto -nH --null -e mundo *.txt")
# (find-quarentenagrep "grep --color=auto -nH --null -e melhor *.txt")
# (find-quarentenagrep "grep --color=auto -nH --null -e prioridade *.txt")
# (find-quarentenagrep "grep --color=auto -nH --null -e antiga *.txt")
# (find-quarentenagrep "grep --color=auto -nH --null -e hip *.txt")
# (find-quarentenagrep "grep --color=auto -nH --null -e apag *.txt")

-- (find-quarentenafile "2de1.txt" "aulas via meet ou zoom")
-- (find-quarentenafile "2de1.txt" "1) tenham dúvidas, 2) venham discutir")
-- (find-quarentenafile "3am2.txt" "todo mundo aprendeu na marra")
-- (find-quarentenafile "3dm2.txt" "MUITISSIMO bem vindas")
-- (find-quarentenafile "3dm4.txt" "me ajudarem a entender a sua pergunta")
-- (find-quarentenafile "2ae2.txt" "Seus chuting skills estao melhores")
-- (find-quarentenafile "2cc2.txt" "descobrir exatamente onde estao as duvidas")

--]]


-- «Marked»  (to ".Marked")
Marked = Class {
  type = "Marked",
  from = function (fname)
      local lines = splitlines(readfile(fname))
      local status = {}
      for i=1,#lines do status[i] = 0 end
      local npage,page = 1,{}
      for i=1,#lines do
        if lines[i]:match("\f") then npage = npage + 1 end
        page[i] = npage
      end
      return Marked {fname=fname, lines=lines, status=status, page=page}
    end,
  __index = {
    nlines = function (m) return #m.lines end,
    mark = function (m, n)
        if m.status[n] then m.status[n] = 1 end
      end,
    markaround = function (m, n, radius)
        for i=n-radius,n+radius do m:mark(i) end
      end,
    markarounds = function (m, pat, radius)
        for i=1,#m.lines do
          if m.lines[i]:match(pat) then m:markaround(i, radius) end
        end
        return m
      end,
    abbr = function (m, n)
        return m.fname:gsub(".txt", "")..m.page[n]
      end,
    abbrp  = function (m, n) return m:abbr(n).." "..n end,
    prefix = function (m, n) return m.fname..":"..i..": " end,
    prefix = function (m, n) return m:abbrp(n).." " end,
    print  = function (m)
        for i=1,m:nlines() do
          if m.status[i] == 1 then print(m:prefix(i)..m.lines[i]) end
        end
        return m
      end,
  },
}


--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "LogsPdfizados1.lua"
chdir "~/logs-pdfizados/"
-- fnames = getoutput "echo ?????.txt"
fnames = getoutput "echo *.txt"
= fnames

for _,fname in ipairs(split(fnames)) do
  print(fname)
  m = Marked.from(fname)
  m:markarounds("prova", 2):print()
end

PP(m.page)
= m:abbr(440)

--]]


printarounds = function (pat)
    chdir "~/logs-pdfizados/"
    -- fnames = getoutput "echo ?????.txt"
    fnames = getoutput "echo *.txt"
    for _,fname in ipairs(split(fnames)) do
      -- print(fname)
      m = Marked.from(fname)
      m:markarounds(pat, 2):print()
    end
  end

args = {...}
if args[1] == "-a" then printarounds(args[2]) end


-- «find-arounds»  (to ".find-arounds")
-- (find-angg ".emacs" "find-arounds")
--[[
;; (find-sh "lua5.1 ~/LUA/LogsPdfizados1.lua -a 'tipo area'")

(defun find-arounds (pat &rest rest)
  (let* ((fmt "lua5.1 ~/LUA/LogsPdfizados1.lua -a '%s'"))
    (apply 'find-sh (format fmt pat) rest)))


--]]




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