Page 1 of 1

[SOLVED] copytree2 function

Published: Dec 13, 2019 - 10:50 AM
by gaelds
Good morning,
I would like the copytree2 function to overwrite files if the folder already exists; what value should be given to onreplace for this to work? "True" and "1" are not acceptable.

Code: Select all

copytree2(r'.\dir',destdir,onreplace=True)
FATAL ERROR: TypeError: 'bool' object is not callable
Exit code: 3

Re: Copytree2 function

Published: Dec 13, 2019 - 4:00 PM
by Aedenth
Good morning,

From what I can see in the function's documentation, it would seem that it is

Code: Select all

onreplace = default_overwrite
which corresponds to what you were looking for.
onreplace (func): callback func(src,dst):boolean called when a file will be replaced to decide what to do.
default is to not replace if target exists. can be default_overwrite or default_overwrite_older or
custom function.

Re: [SOLVED] copytree2 function

Published: Dec 18, 2019 - 10:25
by gaelds
Thank you so much! I'll try it with that