Files

35 lines
749 B
Lua

-- File finder.
-- by H1N1, 2026
-- TODO: make help page!
local function listdir(path, findpattern)
local list = fs.list(path)
for k, v in pairs(list) do
filename = path .. "/" .. v
if fs.isDir(filename) then
listdir(filename, findpattern)
else
if findpattern then
local s, e = filename:find(findpattern)
if s then
local ls = filename:sub(1, s-1)
local h = filename:sub(s, e)
local le = filename:sub(e+1)
local defcolor = term.getTextColor()
write(ls)
term.setTextColor(colors.red)
write(h)
term.setTextColor(defcolor)
print(le)
end
end
end
end
end
local args = {...}
listdir("", args[1])