Jump to content




Making a directory with multiple directories


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

#1 Waterspark63

  • Members
  • 13 posts

Posted 01 August 2018 - 09:12 PM

So a bit of a stupid question, I know in linux if you wanted to make a folder with like 5 folders, each named something else in one command you could do:

sudo mkdir /hi/{1..3}

and it would make 3 folders, 1, 2, and 3 inside the hi folder, is it possible to do this in lua/computercraft?

#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 02 August 2018 - 12:51 AM

Not that I'm aware of. You could certainly write a program that does it, but the support is not there in CraftOS.

#3 Bomb Bloke

    Hobbyist Coder

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

Posted 02 August 2018 - 01:49 AM

Although, in Lua, this is so simple that it might as well be a single command:

for i = 1, 3 do fs.makeDir("/hi/" .. i) end

Note that "hi" doesn't have to exist first.

Using fs.open() to create write-mode file handles will also create any necessary directories within the specified paths, if they're not already present.

Edited by Bomb Bloke, 02 August 2018 - 01:49 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users