private void scanExisting() {
			try {
				// Walk the directory, create or update scripts that exist.
				Set<ScriptFile> scriptsCopy = new HashSet<>(scriptFiles);
				Files.walk(scriptsDirectory).forEach(path -> {
					if (Files.isRegularFile(path)) {
						Optional<ScriptFile> matchingScript = scriptsCopy.stream()
								.filter(script -> script.path().equals(path))
								.findFirst();
						if (matchingScript.isPresent()) {
							scriptsCopy.remove(matchingScript.get());
							onScriptUpdated(path);
						} else {
							onScriptCreate(path);
						}
					}
				});

				// Any remaining items in the set do not exist in the directory, so we remove them.
				scriptFiles.removeAll(scriptsCopy);
			} catch (IOException ex) {
				logger.error("Failed to scan existing scripts in script directory", ex);
			}
		}
Wrapper to manage threaded watch service on the script directory.
recaf-core/src/main/java/software/coley/recaf/services/script/ScriptManager.java