How to copy a folder (divide into sub folders) using Python?
Question: i try to copy a directory (divided into folders and subfolders) to a new
folder that will be created.i work with python 2.7.

  * dir_src = an exist folder 
  * dir_dst = a new folder (not exist) that all the folders will be copied to

I read <https://docs.python.org/2/library/shutil.html> and tried this code:

    
    
    import os,shutil
    
    dir_src = r"C:\Project\layers"
    dir_dst = r"C:\Project\new" 
    for file in os.listdir(dir_src):
        print file 
        src_file = os.path.join(dir_src, file)
        dst_file = os.path.join(dir_dst, file)
        shutil.copytree(src_file, dst_file,symlinks=False, ignore=None)
        print 'copytree'
    

But i get an error:

    
    
    WindowsError: [Error 267] : 'C:\\Project\\layers\\abc.cpg/*.*'
    

Thank you very much for any help.


Answer: The error you are getting (`Permission denied`) should tell you what is the
problem - you don't have rights to read or copy the files. Running the program
as administrator should fix it.

