local function Scan( returnfiles, path )
	local files, dirs = file.Find( (returnfiles and ((path and path.."/" or "").."*.lua") or (path and path or "").."*"), "lsv", "namedesc" );
	
	return (returnfiles and files or dirs);
end

local function ReadFile( filename, mode ) --Custom file.Read function since I overwrite mine. I'll leave this in here so you understand how it works.
	local f = file.Open( filename, "r", mode );
	
	if (!f) then return end
	
	local contents = f:Read( f:Size() );
	f:Close()
	
	return contents;
end

local dirs = Scan( );
local i = 0;
local currentdir = dirs[1];

repeat
	i=i+1
	currentdir = dirs[i] or false;
	
	if (currentdir) then
	
		local scanneddir = Scan( false, currentdir.."/" ) or {};
		
		for k, v in pairs( scanneddir ) do
			scanneddir[k] = tostring(dirs[i]).."/"..v
		end
		
		table.Add( dirs, scanneddir );
	end
until currentdir == false or i == 1000 --Have a safe at 1000 so you don't crash

for _, file in pairs( Scan( true ) ) do --Go through normal lua folder
	print( ReadFile( file, "lsv" ) or "" );
end

for _, dir in pairs( dirs ) do --Go through all the directories we just made
	local files = Scan( true, dir ); --Get the table of all the files
	
	for _, file in pairs( files ) do --Go through all the files
		print( ReadFile( dir.."/"..file, "lsv" ) ); --Print the contents of the file.
	end
end
