|
Post by d354n on Jan 10, 2018 6:29:41 GMT
Anyone can help how how to check if DirectoryExists or not?
Thanks
|
|
|
Post by Mercobots on Jan 11, 2018 0:16:13 GMT
try this
local folder = scriptPath() .. 'folder/' local f = io.open(folder .. "check.lua", "w")
print("Folder - " .. folder)
if f then print("exists") f:close() os.execute("rm -rf \"" .. folder .. "check.lua\"") else print("NOT exists") end
|
|
|
Post by d354n on Jan 11, 2018 19:50:23 GMT
thanks
|
|
ATG
Junior Member
Posts: 79
|
Post by ATG on Aug 19, 2020 9:24:12 GMT
try this local folder = scriptPath() .. 'folder/' local f = io.open(folder .. "check.lua", "w")
print("Folder - " .. folder)
if f then print("exists") f:close() os.execute("rm -rf \"" .. folder .. "check.lua\"") else print("NOT exists") end
Please can you elaborate on this line, esp the "rm -rf \ "" ?
I've look up on Internet for explanation but not able to find info.
os.execute("rm -rf \"" .. folder .. "check.lua\"")
Sorry to dig up this old post. lately I am so active on forum to search for specific answers on different questions I had in mind.
I was looking for how to check whether a folder exist, if not then create one.
Let me put up the the modified code of yours that seem to works for me
function FolderExists(strFolderName) local folder = ROOT .. strFolderName.."/" local f = io.open(folder, "r")
print("Folder - " .. folder)
if f then print("exists") f:close() os.execute("rm -rf \"" .. folder ) else print("NOT exists") os.execute("mkdir "..ROOT..strFolderName) end end
|
|