private void addMetadata(Metadata metadata, String filePerms, String numHardLinks, String fileOwner, String fileOwnerGroup, String fileSize, String lastModDate,
                             String fileName) {
        metadata.add("FilePermissions", filePerms);
        metadata.add("NumHardLinks", numHardLinks);
        metadata.add("FileOwner", fileOwner);
        metadata.add("FileOwnerGroup", fileOwnerGroup);
        metadata.add("FileSize", fileSize);
        metadata.add("LastModifiedDate", lastModDate);
        metadata.add("Filename", fileName);

        if (filePerms.contains("x") && !filePerms.contains("d")) {
            if (metadata.get("NumExecutables") != null) {
                int numExecs = Integer.parseInt(metadata.get("NumExecutables"));
                numExecs++;
                metadata.set("NumExecutables", String.valueOf(numExecs));
            } else {
                metadata.set("NumExecutables", "1");
            }
        }
    }
Parses the output of /bin/ls and counts the number of files and the number of
executables using Tika.
tika-example/src/main/java/org/apache/tika/example/DirListParser.java