I tried to use shutil to delete a directory and all contained files, as follows:
import shutil
from os.path import exists
if exists(path_dir):
shutil.rmtree(path_dir)
Unfortunately, my solution does not work, throwing the following error:
FileNotFoundError: [Errno 2] No such file or directory: '._image1.jpg'
A quick search showed that I'm not alone in having this problem.
In my understanding, the rmtree function is equivalent to the rm -Rf $DIR shell command - but this doesn't seem to be the case.
p.s. for reconstruction purposes. Please create a symbolic link for example using ln -s /path/to/original /path/to/link