zoukankan      html  css  js  c++  java
  • Lua修改文件名


    local lfs = require "lfs"
    local curPath = "..\new\"
    local  totalFile = 0

    local strFormatContain = "xml_Format.xml"

    function attrdir (path)
        for file in lfs.dir(path) do
         local oldName = file
            
            local  a,b = string.find(oldName,strFormatContain)
            local  newName = string.gsub(oldName,strFormatContain,"xml")
            if a ~= nil  then
       
              print(" oldName:  " .. oldName)
              print(" newName:  " .. newName)

               local    result =  os.rename(curPath .. file,curPath .. newName)
              if result then
                totalFile = totalFile + 1
              end

           os.remove(curPath .. file,curPath .. oldName)

           print(" ")        

        end    

       end

    end

    attrdir (curPath)
    print("totalFile: " ,totalFile)

  • 相关阅读:
    图表插件echars的使用案例
    安装Eclipse
    ef 更新数据库
    webapi Route 特性
    WebSite下创建webapi
    C# 泛型约束
    Session共享
    ubuntu eclipse 无法打开
    C# TreeView 连续点击 不触发AfterCheck事件
    ef 仓储模式 Redis
  • 原文地址:https://www.cnblogs.com/cci8go/p/4348634.html
Copyright © 2011-2022 走看看