---@param path string directory
---@param ftype string|string[] file extension
---@return string[] files names
function getFilesInPath(path, ftype)
assert(path, '"path" is required');
-- assert(type(ftype) == 'table' or type(ftype) == 'string', '"ftype" must be a string or array of strings');
local result = {};
for _, thisType in ipairs(type(ftype) == 'table' and ftype or { ftype }) do
local searchHandle, file = findFirstFile(path.."/"..thisType);
table.insert(result, file)
while file do file = findNextFile(searchHandle) table.insert(result, file) end
end
return result;
end
function findFileInFolders(startPath, target)
local list = getFilesInPath(startPath, '*');
for _, filename in pairs(list) do
if (#filename > 2) then
local thisPath = ('%s\\%s'):format(startPath, filename);
if (doesFileExist(('%s\\%s'):format(thisPath, target))) then
return thisPath;
end
end
end
end
print('OK', findFileInFolders('C:\\Users\\amids\\OneDrive\\Documents\\GTA San Andreas User Files\\SAMP\\arizona\\screens', '21.14.31.484.jpg'));