lua 批量重命名文件

local s = io.popen("dir F:\\headicon /b/s")
local filelist = s:read("*all")

local start_pos = 0
local count = 0
while true 
do 
    _,end_pos, line = string.find(filelist, "([^\n\r]+.jpg)", start_pos)
    if not end_pos then 
        break
    end
    count = count + 1
    if count <= 100 then
        os.rename(line , string.format("F:\\headicon\\%s.jpg", count)) 
    end 

    print(line)
    start_pos = end_pos + 1
end

  

posted @ 2017-11-19 22:05  xshang  阅读(1145)  评论(0编辑  收藏  举报