[Python-ideas] Add shutil.ignore_patterns() to shutil.rmtree()
storchaka at gmail.com
Fri May 5 05:52:57 EDT 2017
On 05.05.17 10:58, George Fischhof wrote:
> I have a task to synchronize folders but some files should be remained
> I think this is a very common task.
> I found that shutil.copytree() has ignore_patterns() but rmtree() has not.
> So here comes my idea: add ignore_patterns() to rmtree() it is a good
> feature and makes the functions symmetric.
You can't remove a tree when remain its branches. Thus rmtree() with
ignore_patterns will always fail.
For your particular case I suggest to use os.walk(). You can implement
arbitrary application specific conditions.
More information about the Python-ideas