diff --git a/src/main/java/com/nordstrom/common/file/PathUtils.java b/src/main/java/com/nordstrom/common/file/PathUtils.java index 98150e9..bd8e49b 100644 --- a/src/main/java/com/nordstrom/common/file/PathUtils.java +++ b/src/main/java/com/nordstrom/common/file/PathUtils.java @@ -168,7 +168,7 @@ public static Path getNextPath(Path targetPath, String baseName, String extensio throw new IllegalArgumentException("[extension] must specify a non-empty string"); } - PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher("regex:" + baseName + "(-\\d+)?\\." + extension); + PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher("regex:\\Q" + baseName + "\\E(-\\d+)?\\." + extension); try (Stream stream = Files.walk(targetPath, 1)) { int base = baseName.length();