Looking to a way in lua to get last time an file was modified, on windows
I have seen this post How can I get last modified timestamp in Lua But is a solution for linux :/ can I use io.popen to get the string in windows also?
Looking to a way in lua to get last time an file was modified, on windows
I have seen this post How can I get last modified timestamp in Lua But is a solution for linux :/ can I use io.popen to get the string in windows also?
function get_file_time(filepath)
local pipe = io.popen('dir /4/tw "'..filepath..'"')
local output = pipe:read"*a"
pipe:close()
return output:match"\n(%d.-:%S*)"
end
local filepath = [[C:\path\to\your\file.ext]] -- file must exist
print(get_file_time(filepath))
Use luafilesystem the git https://github.com/keplerproject/luafilesystem
lfs.attributes(<your file path>).modification
is what you searching for
it also work for both Windows and Linux the manual https://keplerproject.github.io/luafilesystem/manual.html