function rename(dirpath,func)
os.execute('dir ' .. dirpath .. ' /b/a -d > temp.txt')
io.input("temp.txt")
local dirname = ""
local files = {}
for line in io.lines() do
if string.find(line,'.bmp') then
table.insert(files,line)
end
end
for k,v in pairs(files) do
name=string.sub(v,1,#v-4)..'_swap'
cmd = 'ren '..dirpath..v..' '..name..'.bmp'
os.execute(cmd)
end
end
rename('C:\\Users\\xx\\Desktop\\bmp\\')
用lua批量改名, 所有bmp文件名加后缀 _swap