Python脚本03 —— 把文件名中的guan-替换成orp
2015-09-22 12:06
441 查看
#把文件名中的guan-替换成orp import os import sys import shutil def file_extension(path): return os.path.splitext(path)[1] def file_name(path): return os.path.splitext(path)[0] def rename(): for f in os.listdir(srcDir): file = os.path.join(srcDir, f) print "find file: " + file if (os.path.isfile(file)) and ("guan-" in file): dstName = f.replace("guan-","orp") dstFile = os.path.join(dstDir, dstName) print "dst file :" + dstFile shutil.copy(file,dstFile) def createNewDir(): isExist = os.path.exists(dstDir) if not isExist: print "dir not exist. create dir: " + dstDir os.mkdir(dstDir) else: print "dir exist: " + dstDir srcDir = sys.path[0] + "/guan/" dstDir = sys.path[0] + "/orp/"; createNewDir() rename()
相关文章推荐
- VBS脚本写的Windows硬件检测工具分享
- 用vbscript实现隐藏任务栏图标的脚本
- 用autoit编写第一个脚本(Hello World)
- VBS调用WMI快速关闭IE的脚本
- 收集的ROS防火墙脚本
- JSP脚本漏洞面面观
- 不错的批处理脚本 第一部分
- VBS脚本加密/解密VBS脚本(简易免杀版1.1)
- 不错的批处理脚本实例代码 第二部分
- 使用脚本和批处理清除电脑中的痕迹的代码第1/2页
- 让你的脚本说话
- Lua脚本获取喜马拉雅MP3音频地址
- 编程界主流脚本编程语言的比较和选择
- 批量文件查找替换功能的vbs脚本
- Powershell脚本的4种执行权限介绍
- Windows Powershell 执行文件和脚本
- PowerShell实现动态获取当前脚本运行时消耗的内存
- 脚本 MsAgent组件 微软精灵 揪出系统自带的宠物
- 百度空间备份脚本baidublogbak.vbs代码分析