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

Making a directory with multiple directories

Started by Waterspark63, 01 August 2018 - 08:12 PM
Waterspark63 #1
Posted 01 August 2018 - 10: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?
KingofGamesYami #2
Posted 02 August 2018 - 01: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.
Bomb Bloke #3
Posted 02 August 2018 - 02: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 on 02 August 2018 - 12:49 AM