dir-spooler-protolib/src/main/java/com/streamsets/pipeline/lib/dirspooler/SpoolDirUtil.java
public static String truncateGlobPatternDirectory(String directory) {
    String[] absolutePath = directory.split(ESCAPED_ASTERISK);
    String truncatedString = absolutePath[0];

    if (lastCharacterIsAsterisk(truncatedString) != SLASH.toCharArray()[0]) {
      List<String> subDirectories = Arrays.asList(truncatedString.split(SLASH));
      StringBuffer stringBuffer = new StringBuffer();
      stringBuffer.append(String.join(SLASH, subDirectories.subList(0, subDirectories.size() - 1))).append(SLASH);
      truncatedString = stringBuffer.toString();
    }

    LOG.debug(String.format("Checking existence of path: %s", truncatedString));
    return truncatedString;
  }
public static String truncateGlobPatternDirectory(String directory) {
    String[] absolutePath = directory.split(ESCAPED_ASTERISK);
    String truncatedString = absolutePath[0];

    if (lastCharacterIsAsterisk(truncatedString) != SLASH.toCharArray()[0]) {
      List<String> subDirectories = Arrays.asList(truncatedString.split(SLASH));
      StringBuffer stringBuffer = new StringBuffer();
      stringBuffer.append(String.join(SLASH, subDirectories.subList(0, subDirectories.size() - 1))).append(SLASH);
      truncatedString = stringBuffer.toString();
    }

    LOG.debug(String.format("Checking existence of path: %s", truncatedString));
    return truncatedString;
  }
Returns the absolute path from the root to the last base directory
Meaning the path until the last / before the first *

@param directory String containing the path to the directory
@return the path truncated to the las complete directory