zoukankan      html  css  js  c++  java
  • python工具程序一、复制目录中指定扩展名的文件

    #!/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:workspaceSrc"
    origLibpath = root_path + r"vcLiblib18x64"
    newLibpath = root_path + r"libdlib18x64"
    
    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:devenvLibvc90x64"
        newLibpath = root_path + r"libdvc90x64"
        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()
    

      

  • 相关阅读:
    perf-stat
    perf原理
    ubuntu中Docker的安装与使用
    NVM相关手册及新特性理解
    #2018BIT软件工程基础#结对项目:四则运算题目生成
    #2018BIT软件工程基础#个人项目:数独
    第一篇博文:自我介绍&新学期展望
    越早明白这些道理,越能少走一些弯路
    把知识连接起来就是创意
    【翻译】24款界面精美的免费UI工具包
  • 原文地址:https://www.cnblogs.com/shankun/p/5164268.html
Copyright © 2011-2022 走看看