#!/usr/bin/env python# coding:utf-8# xcopy Lib directory and rename all files to *d.libimport osfrom os.path import join,e Xistsimport shutilfrom Win32com.shell Import shell, shellconfrom msvcrt Import Getchroot_path = r "E:\WORKSPACE\SRC" Origlibpath = Root_path + R "\vc\lib\lib18x64" Newlibpath = Root_path + R "\libd\lib18x64" if not EXISTS (Origlibpath): Prin T ("Can ' t find original libs!") Else:if os.path.exists (Newlibpath): Shutil.rmtree (Newlibpath) for path, dirs, files in Os.walk (Origl Ibpath): For pre_fname in Files:if not Pre_fname.endswith ('. Lib '): Continue N Ew_fname = Pre_fname.replace ('. ', ' d. ') Pre_fullname = join (path, pre_fname) New_fullname = Join (PAT H.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 = j Oin (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 ("Two lib directories have been copied, file renamed plus d!") Print ("Press any key to exit.") ") Getch ()
Python tool program One, copy files with the extension specified in the directory