I tried Googling this and apparently I need some kind of a file system included.
Does anyone know an easy way to simply list all files in a given directory with as little modification as possible?
 
  CS2D
 CS2D  Scripts
 
Scripts  List files in a directory
 List files in a directory List files in a directory
 List files in a directory 
  1
 1  
 
local file = io.popen("dir /B /A-D "..path, "r")
local file1 = file:read("*l")
local file2 = file:read("*l")
-- ... more files
if filen == nil then
	-- no more files
	file:close()
end
local tempname = os.tmpname()
os.execute("ls -p "..path.." | grep -v / > "..tempname)
local file = io.open(tempname, "r")
local file1 = file:read("*l")
local file2 = file:read("*l")
-- ... more files
if filen == nil then
	-- no more files
	file:close()
	os.remove(tempname)
end
 Mami Tomoe: this is the faster way
 Mami Tomoe: this is the faster wayos.execute('rd /s/q "'..dir..'"')
 §5.1 - Show good behavior and simply don't be a stupid asshole
 §5.1 - Show good behavior and simply don't be a stupid asshole  Unknown_Cheater has written
 Unknown_Cheater has written Mami Tomoe has written
 Mami Tomoe has writtenfunction table.mergeValues(tbl, tbl2)
    for k, v in pairs(tbl2) do 
        table.insert(tbl, v)
    end
end
function io.isDirectory(path)
    -- This can be removed if io.isdir gets updated
    path = (path:sub(-1) == "/" or path:sub(-1) == "\\") and path:sub(1, -2) or path
    return io.isdir(path)
end
function io.getPaths(directory)
    local paths = {}
    for file in io.enumdir(directory) do
        if file ~= '.' and file ~= '..' then
            path = directory..file
            path = io.isDirectory(path) and path.."/" or path
 
            table.insert(paths, path)
        end
    end
    return paths
end
function io.getFilePaths(directory, deep)
    local filePaths = {}
    for _, path in pairs(io.getPaths(directory)) do
        if deep and io.isDirectory(path) then
            table.mergeValues(filePaths, io.getFilePaths(path, deep))
        else 
            table.insert(filePaths, path)
        end
    end
    return filePaths
end
function io.getDirectoryPaths(directory, deep)
    local directoryPaths = {}
    for _, path in pairs(io.getPaths(directory)) do
        if io.isDirectory(path) then
            table.insert(directoryPaths, path)
            if deep then
                table.mergeValues(directoryPaths, io.getDirectoryPaths(path, deep))
            end
        end
    end
    return directoryPaths
end
function dofileDirectory(directory, formats, deep)
    for _, filePath in pairs(io.getFilePaths(directory, deep)) do
        if type(formats) == "table" then
            for _, format in pairs(formats) do
                if filePath:sub(-4) == format then
                    dofile(filePath)
                end
            end
        elseif filePath:sub(-4) == formats then
            dofile(filePath)
        end
    end
end
local function getLocalPath()
    local str = debug.getinfo(2, "S").source:sub(2)
    return str:match("(.*/)")
end
 
  1
 1  
 