1. 程式人生 > >lua批量重新命名檔案

lua批量重新命名檔案

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

local start_pos = 0
local count = 100
while true
do
    _,end_pos, line = string.find(filelist, "([^\n\r]+.png)", start_pos)
    
    if not end_pos then
        break
    end
    count = count + 1

    if count <= 115 then
    	local name = "a" .. count .. 8
        os.rename(line , string.format("F:\\headicon\\%s.png", name))
    end
 
    start_pos = end_pos + 1
end

print("++++++重新命名完成+++++")