finding locations of many files via kpse
Erik Nijenhuis
erik at xerdi.com
Thu Jul 4 09:34:15 CEST 2024
I was a little bit confusing for option two I guess. Here's the MWE:
Execute with: texlua kpse_search.lua
For example:
texlua kpse_search.lua logo.png gitinfo-lua.lua lua-placeholders.sty
Prints:
Found: logo.png -> /home/erik/texmf/tex/generic/images/logo.png
Found: gitinfo-lua.lua -> /home/erik/src/latex/gitinfo-lua/scripts/gitinfo-
lua.lua
Found: lua-placeholders.sty -> /home/erik/src/latex/lua-placeholders/tex/lua-
placeholders.sty
Contents kpse_search.lua:
-- kpse_search.lua
local kpse = kpse or require 'kpse'
kpse.set_program_name('lualatex')
local function print_usage()
print("Usage: kpse_search.lua <path1> <path2> ... <pathN>")
end
local paths = arg
if #paths == 0 then
print("No paths provided.")
print_usage()
os.exit(1)
end
for _, path in ipairs(paths) do
local result = kpse.find_file(path)
if result then
print(string.format("Found: %s -> %s", path, result))
else
print(string.format("Not found: %s", path))
end
end
-- end of file
Sorry for the earlier clutter :|
More information about the texhax
mailing list.