import os
from posixpath import dirname
import subprocess
import sys
targetProjectPath = sys.argv[1]
tempBatFile = open("temp.bat", "w")
existDirs = [f for f in os.listdir(os.getcwd()) if os.path.isdir(f)]
for subDir in existDirs:
if os.path.exists("{}/{}".format(os.getcwd(), subDir)):
os.remove(subDir)
targetDirs = [f for f in os.listdir(targetProjectPath) if os.path.isdir("{}/{}".format(targetProjectPath, f))]
print(targetDirs)
for subDir in targetDirs:
if subDir == "obj" or subDir == "Temp" or subDir == "Logs":
continue
path = "mklink /J {} {}\{}\n".format(subDir, targetProjectPath, subDir)
tempBatFile.write(path)
tempBatFile.close()
subprocess.call([r'temp.bat'])
print("complete")
使用方法找个空文件夹新建两个脚本配置bat脚本的路径双击bat脚本python脚本import osfrom posixpath import dirnameimport subprocessimport systargetProjectPath = sys.argv[1]tempBatFile = open("temp.bat", "w")existDirs = [f for f in os.listdir(os.getcwd()) if os.path.isdir(f)