Python, copy only directories
Question: I have a program that has a list of some files. I have to copy only the
directories and the subdirectories from the list to a specified directories
and don't need to copy the files. I tried this, but it doesn't work.

    
    
    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)
    


Answer: Try this:

    
    
    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
    

