我正在研究将某些目录的子文件夹复制到新目录的代码。我觉得我已经尝试了一切,但我似乎无法让他们复制。仅复制子文件夹所在的文件夹和文件。到目前为止,以下是我的代码:
for cust in MULTIPLE_FOLDERS_LIST:
if cust in clientName:
for root, dirs, files in os.walk('\\'.join(configDir.split('\\'))):
for direc in dirs:
if cust in direc and not os.path.exists('\\'.join(customerConfigCustomFolderPath.split
('\\'))+'\\'+direc):
shutil.copytree('\\'.join(configDir.split('\\'))+'\\'+direc, '\\'.join(customerConfigCustomFolderPath.split('\\')[:-1])+'\\'+direc)
位置似乎是正确的(必须相对地定位目录)。如果有人有任何想法,将不胜感激!