遍历指定文件夹中特定某个格式的文件 (lua编写)
2014-10-16 10:02
417 查看
require"lfs"
--遍历某个文件夹中特定格式的文件,并插入到表格中
function findtemp(path,wefind,filetable)
for file in lfs.dir(path) do
if string.find(file,wefind) then
table.insert(filetable,file)
end
end
end
--搜索某盘中特定的文件夹
function findindir(path,wefind,filetable)
for file in lfs.dir(path) do
local f=path..'\\'..file
if string.find(f,wefind) then
findtemp(f,"%.csv",filetable)
return
end
end
end
local crrentFolder=[[F:]]
------------------------------
local filetable={}
findindir(crrentFolder,"temp",filetable)
i=1
--输出某个特定文件夹中某个格式的所有文件名
while filetable[i]~=nil do
print(filetable[i])
i=i+1
end
--遍历某个文件夹中特定格式的文件,并插入到表格中
function findtemp(path,wefind,filetable)
for file in lfs.dir(path) do
if string.find(file,wefind) then
table.insert(filetable,file)
end
end
end
--搜索某盘中特定的文件夹
function findindir(path,wefind,filetable)
for file in lfs.dir(path) do
local f=path..'\\'..file
if string.find(f,wefind) then
findtemp(f,"%.csv",filetable)
return
end
end
end
local crrentFolder=[[F:]]
------------------------------
local filetable={}
findindir(crrentFolder,"temp",filetable)
i=1
--输出某个特定文件夹中某个格式的所有文件名
while filetable[i]~=nil do
print(filetable[i])
i=i+1
end
相关文章推荐
- Qt文件操作:遍历文件夹中 指定格式的文件,并添加文件名到comboBox上
- 基于C++和MFC遍历指定文件夹下指定格式的文件
- C# 遍历指定文件夹下的指定格式文件
- Android递归遍历文件夹中指定格式文件
- python遍历文件夹并删除特定格式文件的示例
- 遍历指定文件夹的指定格式的文件并且copy到指定的文件夹下面
- python遍历文件夹并删除特定格式文件的示例
- Python遍历文件夹,删除空文件夹,过滤特定大小和格式的文件
- java遍历删除windows下的指定文件夹下面的相同格式或指定格式的file文件
- MATLAB遍历主文件夹下所有子文件里的特定格式文件
- python遍历文件夹获取指定格式的文件
- [安卓源代码]简单实现SD卡上遍历所有文件夹寻找指定格式文件
- java遍历删除指定文件夹下面的相同格式或指定格式的file文件
- Java遍历文件夹&读取指定格式的文件zUI金
- Java 遍历文件夹 取出指定文件格式的文件
- 遍历文件夹 非递归 只收集指定后缀的文件
- 用python查找指定格式或名称的文件及修改指定文件夹名称
- C# 删除、遍历指定目录下的所有指定文件、文件夹
- 非递归遍历指定文件夹下的所有文件及其子文件夹 [11/29/2010 更新]
- 【转】C#遍历指定文件夹中的所有文件