Jump to content




List all folders but no files from a directory in program

lua

3 replies to this topic

#1 TechnicalCoding

  • Members
  • 35 posts

Posted 12 June 2016 - 09:26 PM

Look at title!

I have been searching for hours please help

#2 Incinirate

  • Members
  • 216 posts
  • LocationDanktown, Memeland

Posted 12 June 2016 - 09:31 PM

use fs.list in conjunction with fs.isDir (isDirectory)
function listFolders(directory)
	local all = fs.list(directory)
	local tab = {}
	for i=1,#all do
		if fs.isDir( fs.combine(directory, all[i] ) ) then
			table.insert(tab, all[i])
		end
	end
	return tab
end

Edited by Incinirate, 13 June 2016 - 01:19 AM.


#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 13 June 2016 - 01:08 AM

You may need to change a line:

if fs.isDir( fs.combine(directory, all[i] ) ) then


#4 Incinirate

  • Members
  • 216 posts
  • LocationDanktown, Memeland

Posted 13 June 2016 - 01:19 AM

View PostBomb Bloke, on 13 June 2016 - 01:08 AM, said:

You may need to change a line:

if fs.isDir( fs.combine(directory, all[i] ) ) then

Ahh thanks, slipped my mind. :P
Edited.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users