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("\n")
end
end
end
attrdir (curPath)
print("totalFile: " ,totalFile)
Lua修改文件名的更多相关文章
- Python 批量修改文件名
最近下载了几部美剧(越狱.迷失.权利的游戏......),每集文件名都好长好长..想改短一些,但一个一个改太累了,于是写了个脚本来实现批量修改: 修改前文件名: 修改后文件名: 代码实现: #enco ...
- 使用Java中File类批量创建文件和批量修改文件名
批量创建文件 int cont = 1; String s = "E:\\学习资料\\Java笔记-"; while(cont<100){ File f = new File ...
- git修改文件名大小写的方法。
首先,在git命令行里面运行: git config core.ignorecase false 此命令是全局设置,以后在此机子上clone出来的git仓库工程都沿用此设置.当然,以前就已经clone ...
- linux下批量修改文件名之rename
最近因为突然用到需匹配更换文件名,发现rename命令真是 简单好用,和sed语法及vim 替换很相似. 1. 更改文件名后缀 rename 's/\.txt/\.html/' * 2.增加文件名后缀 ...
- Linux下find一次查找多个指定类型文件,指定文件或者排除某类文件,在 GREP 中匹配多个关键 批量修改文件名等
http://blog.sina.com.cn/s/blog_62e7fe670101dg9d.html linux下二进制文件查找: strings 0000.ts | grep -o " ...
- utf-8转换为ansi和修改文件名的批处理(可解决source insight中文注释乱码问题)
source insight中文乱码有两个原因,一个是source insight的设置不正确.另外一个原因是源文件是utf-8格式的. 最近在工作中用source insight 查看jsp文件.j ...
- [转载][记录]shell 批量修改文件名
参考了:[新手入门] shell脚本批量修改文件名 4楼回复 我刚好是在vagrant+ubuntu中进行开发,windows手动修改太麻烦. #!/bin/ksh ls *.htm | while ...
- linux批量修改文件名的shell脚本
linux中批量修改文件名的shell脚本代码,主要是使用了rename,结合shell,喜欢的朋友可以参考下 使用 rename 命令 ======================== NAME ...
- java 修改文件名
// 修改文件名 public static boolean modifyFileName(String serverPath, String oldFileName, String newLogin ...
随机推荐
- u盘中放入大于4g单独文件失败解决
u盘中文件格式通常为FAT32,需要转换为NTFS格式 在win7中cmd调出命令行,输入: convert H: /fs:ntfs (H为u盘位置)
- 《DSP using MATLAB》示例Example4.10
上代码: b = [1, 0.4*sqrt(2)]; a = [1, -0.8*sqrt(2), 0.64]; % compute the polynomials coefficients given ...
- 《DSP using MATLAB》示例Example4.5
代码: x1 = [1, 2, 3]; x2 = [2, 4, 3, 5]; % x1 x2 sequences % n1 = 0:1:2; n2 = 0:1:3; n1 = -1:1:1; n2 = ...
- Codeforces Round #341 (Div. 2)
在家都变的懒惰了,好久没写题解了,补补CF 模拟 A - Wet Shark and Odd and Even #include <bits/stdc++.h> typedef long ...
- UVa1515 Pool construction(最小割)
题目 Source https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- EF框架step by step(5)—处理实体简单属性
EF框架会对实体进行跟踪,对实体的每个属性当前值和原始值及其状态进行跟踪,记录.当前值是指实体属性当前的被赋予的值,而原始值是指实体最初从数据库读取或者附加到DbContext时的值. 先通过简单的代 ...
- WPF:依赖属性的数据绑定
One of the strengths of WPF is its data binding capabilities. Although data binding is not new (in f ...
- 【Xcelsius】在PPT中嵌入水晶易表Xcelsius2008仪表盘
如果您使用Xcelsius创建了动画图形,并将其保存为 Shockwave® 文件(.swf 文件扩展名).但是往往插入进去之后,会产生一些比较棘手的问题,比如ppt不会自动播放,错误等等.今天把这些 ...
- Python: 常用list, string处理功能
#1. keep strings in double quote as one word when split string to words #e.g. str = ‘a b "is si ...
- Storm实战集锦
一.Kafka+Storm+HDFS整合实践 本文导读: 前言 Kafka安装配置 Storm安装配置 整合Kafka+Storm 整合Storm+HDFS 整合Kafka+Storm+HDFS 参考 ...