diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/FileUtil.java b/Core/src/org/sleuthkit/autopsy/coreutils/FileUtil.java index 29277217bf..1fe67dcd3f 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/FileUtil.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/FileUtil.java @@ -169,8 +169,9 @@ public class FileUtil { public static String escapeFileName(String fileName) { //for now escaping /:"*?<>| (not valid in file name, at least on Windows) //with underscores. We are only keeping \ as it could be part of the path. - return fileName.replaceAll("[\\p{Cntrl}/:\"*?<>|]+", "_"); - } + // Also trim empty space characters at the end of file name. + return fileName.replaceAll("[\\p{Cntrl}/:\"*?<>|]+", "_").trim(); + } /** * Test if the current user has read and write access to the dirPath.