文章摘要
文章介绍了一种使用Lua脚本和tab库的工具,用于检查所有.txt文件的填写是否符合规定。该工具通过获取目标路径下的所有.txt文件路径,并将这些路径保存到filename.txt中。随后,程序遍历filename.txt中的每一行,检查每行的Tab数量是否超过20,并标记填写不规范的行。此外,文章还提到在不同操作系统下可以通过命令行工具(如dir在Windows、ls在Linux)获取文件路径。文章的核心内容是提供一种自动化的方式确保.txt文件的填写规范性。
–[[检查所有.txt文件
比如A.txt中第一行规定有20列,但是在X行中多输入一个Tab,则输出:A表的X行填写不规范,行末有多余填写
]]
–[[检查所有.txt文件
比如A.txt中第一行规定有20列,但是在X行中多输入一个Tab,则输出:A表的X行填写不规范,行末有多余填写
]]
getinfo=io.popen(‘dir https://www.jb51.net//file /b /s’)
all=getinfo:read(‘*all’)
local filenameList=io.open(“filename.txt”, “wb”)
filenameList:write(“Path/n”)
filenameList:close()
filenameList=io.open(“filename.txt”, “a”)
filenameList:write(all)
io.close(filenameList)
io.close(getinfo)
local filenameList=tab.Open([[https://www.jb51.net/filename.txt]], “Path”, false)
for index, Row in ipairs(filenameList) do
local pathlist=Row[“Path”]
local rowString=string.find(pathlist, “.txt”)
if rowString ~=nil and rowString ~=”” then
moon.CheckRowlength(pathlist, pathlist)
end
end
io.popen(‘dir /b /s’)是windows下的,通过执行命令行dir获得
io.popen(‘ls’)是linux下的
© 版权声明
文章版权归作者所有,未经允许请勿转载。