Directory:move(path) method
Moves the folder physically on the disk and all contained files and subdirectories, to the specified path.
Parameters
path
A string representing the destination path.
Return value
Returns true if the operation succeeded or false otherwise (if a file is open in another program for example).Example
function rename_dir(oldpath, newpath)
local dir = sys.Directory(oldpath)
if dir.exists then
return dir:move(newpath)
end
return false
end
-- create a "test" directory in current folder
sys.Directory("test"):make()
-- rename it to "newtest"
rename_dir("test", "newtest")