You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
793 B

import os
import shutil
sourcePath = 'D:\\python\\TangDou\\AcWing'
targetPath = 'D:\\python\\TangDou'
listDir = os.listdir(targetPath) # 获取当前目录下的所有内容
fmt = "\\.clang-format"
vscd = "\\.vscode"
for x in listDir:
fName = os.path.join(targetPath, x)
if os.path.isdir(fName) and fName != sourcePath:
# 拷贝文件和一个子目录到目标目录下
ta = fName + fmt
if os.path.exists(ta):
os.remove(ta)
shutil.copy(sourcePath + fmt, ta)
tb = fName + vscd
if os.path.exists(tb):
shutil.rmtree(tb)
shutil.copytree(sourcePath + vscd, tb)
print("成功拷贝完成:" + fName)
print("恭喜,配置文件同步到所有工作目录!")