This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Varscott11's profile picture

Test for a sub directory

Started by Varscott11, 01 November 2016 - 08:16 PM
Varscott11 #1
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 on 01 November 2016 - 08:17 PM
Lupus590 #2
Posted 01 November 2016 - 10:02 PM
how are you expecting it to work? show what you have tried to do in code.
TheRockettek #3
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
Bomb Bloke #4
Posted 02 November 2016 - 11:01 AM
You'd want to combine before passing to isDir, but yeah, basically.
Varscott11 #5
Posted 02 November 2016 - 07:31 PM
I've tried out this method and it works great. Thanks for the support!