Skip to main content
3 of 9
deleted 54 characters in body
Patrick
  • 369
  • 2
  • 3
  • 11

How to copy a directory structure to another, but only copying specific files in python 2.7?

def ignore_list(path, files):

filesToIgnore = []

allowedExtensionList = ['pyc', 'ui', 'txt']

fileNameList = ['__main__.py', 'myfile.bat']

for fileName in files:
   
    fullFileName = os.path.join(os.path.normpath(path), fileName)

    fName, fileExtension = os.path.splitext(os.path.basename(fullFileName))

    if fName not in fileNameList or fileExtension not in allowedExtensionList:       

        filesToIgnore.append(fileName)

return filesToIgnore

start of script

shutil.copytree(srcDir, dstDir, ignore=ignore_list)

This code has produced empty folder. I don't know why the folder is empty, how can i correct this ?

Patrick
  • 369
  • 2
  • 3
  • 11