diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptFileWatcher.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptFileWatcher.java index 3fd277d315..5a9b90c97f 100644 --- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptFileWatcher.java +++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptFileWatcher.java @@ -207,10 +207,10 @@ public abstract class AbstractScriptFileWatcher extends AbstractWatchService imp if (file.isDirectory()) { if (watchSubDirectories()) { synchronized (this) { - String prefix = file.toString() + File.separator; - var toRemove = loaded.stream() + String prefix = file.toURI().toURL().getPath(); + Set toRemove = loaded.stream() .filter(f -> f.getScriptFileURL().getFile().startsWith(prefix)) - .collect(Collectors.toList()); + .collect(Collectors.toSet()); toRemove.forEach(this::removeFile); } }