Detecting files of a certain type and displaying them with derma

Is it possible to scan a directory (either as a folder in the garrysmod directory, or on an external web server with the latter being optimal) for a certain type of file, for example, an mp3 and if the scan comes up with results, it displays the name of the file in a list? Of course, if I was to add a new mp3 file to that directory and do another scan, another file would be added to the list.

It’s kinda obvious what I’m trying to do here I think, I can make playing the mp3 easy enough, but adding the files to the system is what I’m confused about.

Of course you can. (I can show you how to do it in garrysmod not from a web server)

Do you just want a simple list displaying all the songs and be able to just copy and paste their directory?

I used a similar system to detect plugins and auto addcsluafile + include them.



local files, foldername = file.Find("sound/your/path/here/*.mp3", "MOD")


[lua]
local snds = {}
local function GenerateFileNames(dir, ext)
local f,d = file.Find(dir…"/*", “GAME”)

for k,v in ipairs(d) do
	GenerateFileNames(dir.."/"..v, ext)
end

for k,v in ipairs(f) do
	if !ext[string.sub(v, -4)] then continue end
	snds[#snds+1] = dir.."/"..v
end

end

GenerateFileNames(“sound”, {[".mp3"] = 0})
[/lua]

Just to let you know “file.Find()” is very pricey.