I am relatively new to python. I am trying to copy a directory to another directory maintaining the structure.
I am using
shutil.copytree(src, dst, symlinks=False, ignore=None,
copy_function=copy2, ignore_dangling_symlinks=False)
I am trying to write a call back function for ignore.
My aim is to take a list of files in a list , and copy only those files,ignoring the rest. How do we pass a list into the call back function?
I wrote a simple call back function , but I get some error when I try to run the copyTree function
def abc(src,names):
print(src)
print(names)
Traceback (most recent call last):
File "<pyshell#23>", line 1, in <module>
shutil.copytree('D:\Mytest','D:\PythonTestDest3',symlinks=False,ignore=abc)
File "C:\Python32\lib\shutil.py", line 204, in copytree
if name in ignored_names:
TypeError: argument of type 'NoneType' is not iterable
return [f for f in files if not is_dir(os.path.join(folder, f)) and f not in copy_these]
. – Allenaallenby