-- -- extract file name list by DOS "dir" command -- filename = "filelist.txt" filename_out = "filelist_out.txt" fileext = "lua" os.execute("dir /b *."..fileext.." > "..filename) fr = io.open(filename) fw = io.open(filename_out, "w") for line in fr:lines() do --i:position of 1st found string --j:position of 2nd found string --k:substring of 1st found string --l:substring of 2nd found string i,j,k,l=string.find(line, "(.+)%.(.+)") print(line.." "..i.." "..j..":"..k..":"..l) fw:write(k.."\n") end fr:close() fw:close()