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 ...
随机推荐
- Liferay 6.2 改造系列之二十二:如何发布WAR包
1.修改web资源并发布 如果修改了默认主题信息,需执行portal-web中的build-themes任务: 执行portal-web中的deploy任务: 2.修改portal-impl中的jav ...
- express-5 质量保证(2)
跨页测试 跨页测试更有挑战性,因为需要你控制和观测浏览器. 现在设置一个跨页测试情境的例子.比如,你的网站上有一个包含联系表单的Request Group Rate页面.营销部门想知道客户是从哪个页面 ...
- http://blog.csdn.net/lipeng32768/article/details/50845547
http://blog.csdn.net/lipeng32768/article/details/50845547
- three.js阴影
<!DOCTYPE html> <html> <head> <title>Example 01.03 - Materials and light< ...
- WPF中获取形状范围
在没加入到Canvas时,也能获取形状的方法: var polygon = new Polygon(); polygon.Points.Add(new Point(xStart, yStart)); ...
- uva 107 - The Cat in the Hat
The Cat in the Hat Background (An homage to Theodore Seuss Geisel) The Cat in the Hat is a nasty c ...
- CodeForces#275--DIV 2--B(BinarySearch)(!!)
B. Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Javascript的console.log()用法
Firebug & Chrome Console 控制台的一些其他功能console.log(object[, object, ...])使用频率最高的一条语句:向控制台输出一条消息.支持 C ...
- ACM 兰州烧饼
兰州烧饼 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描述 烧饼有两面,要做好一个兰州烧饼,要两面都弄热.当然,一次只能弄一个的话,效率就太低了.有这么一个大平底锅,一 ...
- Linux下bash: scp: command not found问题 或者装ssh包时报错 Requires: libedit.so.0()(64bit)
一.用scp命令从物理主机向CentOS 6.1虚拟机传送文件,提示以下错误:bash: scp: command not found到CentOS 6.1虚拟机查看也缺少scp命令.该虚拟机 ...