python工具程序一、复制目录中指定扩展名的文件
2016-01-27 18:51
1001 查看
#!/usr/bin/env python # coding:utf-8 # xcopy Lib directory and rename all files to *d.lib import os from os.path import join,exists import shutil from win32com.shell import shell, shellcon from msvcrt import getch root_path = r"E:\workspace\Src" origLibpath = root_path + r"\vc\Lib\lib18x64" newLibpath = root_path + r"\libd\lib18x64" if not exists(origLibpath): print("Can't find original libs!") else: if os.path.exists(newLibpath): shutil.rmtree(newLibpath) for path, dirs, files in os.walk(origLibpath): for pre_fname in files: if not pre_fname.endswith('.lib'): continue new_fname = pre_fname.replace('.', 'd.') pre_fullname = join(path, pre_fname) new_fullname = join(path.replace(origLibpath, newLibpath), new_fname) shell.SHFileOperation((0, shellcon.FO_COPY, pre_fullname, new_fullname, shellcon.FOF_NOCONFIRMMKDIR, None, None)) origLibpath = r"D:\devenv\Lib\vc90x64" newLibpath = root_path + r"\libd\vc90x64" for path, dirs, files in os.walk(origLibpath): for pre_fname in files: if not pre_fname.endswith('.lib'): continue new_fname = pre_fname.replace('.', 'd.') pre_fullname = join(path, pre_fname) new_fullname = join(path.replace(origLibpath, newLibpath), new_fname) shell.SHFileOperation((0, shellcon.FO_COPY, pre_fullname, new_fullname, shellcon.FOF_NOCONFIRMATION|shellcon.FOF_NOCONFIRMMKDIR, None, None)) print("已复制了两处 Lib目录,文件重命名加d!") print("按任意键退出。") getch()
相关文章推荐
- 细说python类3——类的创建过程
- 局部敏感哈希(原始LSH)python实现
- python安装tar.gz和whl模块
- Python import
- Python学习之路-初学篇之Python的基本数据类型(一)
- python excel操作
- 构建Python+Selenium2自动化测试环境<一>
- python 脚本查看微信把你删除的好友--win系统版
- python学习新得
- Python字符串笔录
- python 类的简单介绍
- Python 第八章 进程和线程
- day2 学习python 字符及字符串
- 模重复平方计算法(快速幂)【Python实现】<信安数论>
- Python & JSON
- Python2.7 读取中文,显示为乱码的问题
- ubuntu14.04 源码安装 Python2.7.11
- Black Hat python-2.1
- python Pillow 模块安装
- 1.27 python21行代码拼写检测 50行代码检测语言