1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
function forfiles(path)
local i, t, popen = 0, {}, io.popen
local s = 'cmd /c echo @FNAME;@EXT;@PATH;@RELPATH;@ISDIR;@FSIZE;@FDATE;@FTIME'
local cmd = string.format('forfiles /p %s /s /m * /c "%s"', path, s)
for filename in popen(cmd):lines() do
i = i + 1
t[i] = filename
end
return t
end
function extractfilepath(filename)
return string.sub(filename, string.find(filename, '.+\\'))
end
local t = forfiles(extractfilepath(arg[0]))
io.output('output.txt')
for i = 1, #t do
local _, _, fname, ext, path, relpath, isdir, fsize, fdate, ftime = string.find(
t[i],
'"(.+)";"(.+)";"(.+)";"(.+)";(.+);(.+);(.+);(.+)'
)
if _ then
io.write(string.format(
string.rep('%s\n', 8),
fname, ext, path, relpath, isdir, fsize, fdate, ftime
))
end
end |
Partager