diff --git a/src/spikeinterface/preprocessing/motion.py b/src/spikeinterface/preprocessing/motion.py index 71ae3f3ebb..ce6b9bb337 100644 --- a/src/spikeinterface/preprocessing/motion.py +++ b/src/spikeinterface/preprocessing/motion.py @@ -320,12 +320,12 @@ def correct_motion( if folder is not None: folder = Path(folder) if overwrite: - if folder.exists(): + if folder.is_dir(): import shutil shutil.rmtree(folder) else: - assert not folder.exists(), f"Folder {folder} already exists" + assert not folder.is_dir(), f"Folder {folder} already exists" folder.mkdir(exist_ok=True, parents=True)