2016-06-23 2 views
1

일부 파일 목록이있는 프로그램이 있습니다. 목록에서 지정된 디렉토리로 디렉토리와 서브 디렉토리 만 복사해야하며 파일을 복사 할 필요가 없습니다. 나는 이것을 시도했지만 효과가 없다.Python, 디렉토리 만 복사

def copiarDirs(): 
items = list.curselection()    
desti = tkFileDialog.askdirectory() 
for dirs in os.walk(items, topdown=False): 
    for name in dirs: 
    #for i in items :      
     aux=root+"/"+list.get(i)    
     tryhard=("cp "+str(aux)+" "+str(desti)) 
     os.system(tryhard) 

답변

0

이 시도 :

import os 

def copyDirs(source, destination): 
    for subdir, dirs, files in os.walk(source): 
     for f in files: 
      dir = destination + os.path.join(subdir).split(':')[1] 
      if not os.path.exists(dir): 
       os.makedirs(dir) 

sourceDir = 'D:\\Work\\' 
destDir = 'D:\\Dest\\' 
copyDirs(sourceDir, destDir) #calling function 
+0

미안하지만이 작동하지 않습니다. addittion에서 나는 curselection 디렉토리 만 복사하면된다. – mileswiles