1. Traverse all lua files under the file, This can be changed, only use luaforwindow to execute
< /div>
- –dofile(“F:/Program_Files/Lua/lua_script/csvtolua/get_csv.lua”)
- require”lfs”
- functionfindindir(path,wefind,r_table,intofolder )
- for file in lfs.dir(path) do
- If file~=”.” and file~= “..” then
- local f = path.. ‘\\’..file
- –print(“/t”..f)
- if string.find(f, wefind) ~= nil then
- –print(“/t”..f)
- table.insert(r_table,f)
- end end
- local attr=lfs.attributes(f)
- ass ert(type(attr)==”table”)
- If attr.mode== “directory” and intofolder then
- findindir (f, wefind, r_table, intofolder)
- Else
- –for name, value in pairs(attr) do
- print (name, value)
- end end
- end
- end
- end
- local currentFolder=[[F:\Program_Files\Lua\lua_script\csvtolua]]
- —————— ——————-
- local input_table={}
- findindir(currentFolder, “%.lua”, input_table, false)–Find the lua file, you can change it here
- i=1
- while input_table[i]~=nil do
- print(input_table[i])
- i=i+1
- end
This is the result of execution:< /span>
1. Traverse all the lua files under the file, this can be changed, you need to use luaforwindow to execute
< ol start="1" style="border-top:none;border-right:1px solid rgb(231,229,220);border-bottom:none;border-left:none;background-color:rgb(255,255,255);color:rgb (92,92,92);">
< li style="border-top:none;border-right:none;border-bottom:none;border-left:3px solid rgb(108,226,108);background-color:rgb(248,248,248);line-height:18px;list- style-position:outside;">local f = path..’\\’..file
< /ol>
This is the result of execution:
- –dofile(“F:/Program_Files/Lua/lua_script/csvtolua/get_csv.lua”)
- require”lfs”
- functionfindindir(path,wefind,r_table,intofolder)
- for file in lfs.dir(path)
- if file~=”.” and file~=”..” then
- local f=path..’\\’..file< /li>
- –p rint(“/t”..f)
- if string.find(f, wefind) ~= nil then
- Print(“/t”..f)
- table.insert(r_table, f)
- end end
- local attr=lfs.attributes(f)
- Assert (type(attr)==”table”)
- ifattr.mode==”directory”and intofolderthen
- findindir(f,wefind,r_table,intofolder)
- –for name, value in pairs(attr) do
- Print (name, value)
- end end< /li>
- end
- end
- end
- local currentFolder = [[F:\Program_Files\Lua\lua_script\csvtolua]]
- ————————————-
- local input_table = {}
- findindir(currentFolder, “%.lua”, input_table, false)–查找lua文件,这里可以改的
- i=1
- while input_table[i]~=nil do
- print(input_table[i])
- i=i+1
- end
< li style="border-top:none;border-right:none;border-bottom:none;border-left:3px solid rgb(108,226,108);background-color:rgb(248,248,248);line-height:18px;list- style-position:outside;"> else Else
[plain] view plain copy