Jump to content




Test for a sub directory


  • You cannot reply to this topic
4 replies to this topic

#1 Varscott11

  • Members
  • 23 posts

Posted 01 November 2016 - 09:16 PM

I'm sure there is a way, but I can't find it. I need my program to test to see if there is at least one sub directory folder in another folder. The name or whatever doesn't matter

("UO_Users/") --Test for any subdir in this folder.

I've tried fs.list, but the table it produces never seems to work like it should

Any help appreciated :)

Edited by Varscott11, 01 November 2016 - 09:17 PM.


#2 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

Posted 01 November 2016 - 10:02 PM

how are you expecting it to work? show what you have tried to do in code.

#3 TheRockettek

  • Members
  • 547 posts
  • LocationRem is best girl

Posted 02 November 2016 - 07:23 AM

files = fs.list(dir)
for i,k in pairs(files) do
if fs.isDir(k) then
return fs.combine(dir,k)
end
end

#4 Bomb Bloke

    Hobbyist Coder

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

Posted 02 November 2016 - 11:01 AM

You'd want to combine before passing to isDir, but yeah, basically.

#5 Varscott11

  • Members
  • 23 posts

Posted 02 November 2016 - 07:31 PM

I've tried out this method and it works great. Thanks for the support!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users