Search code examples
javaparsingmetadataexiftool

Including duplicates in ExifTool output with Unspecified Tag


I'm trying to replicate the following command in Java, to capture the file names of some files in a zip.

ExifTool.exe -a -ZipFileName C:\Users\Name\Downloads\file.zip

This gives the following output

Zip File Name                   : Scheme02_V1.tiff
Zip File Name                   : SupplementaryMaterialFigures_V1.docx
Zip File Name                   : SupplementaryMaterialTables_V1.docx

To do this using the mjeanroy java library, I've created a new UnspecifiedTag, to retrieve the zip file name.

UnspecifiedTag zipFileNameTag = new UnspecifiedTag(ZIP_FILE_NAME);

in addition to a new execution strategy which includes the "-a" tag for duplicates.

However, this only seems to capture 1 document from the zip file.

Map<Tag, String> zipFileNameMap =
                    tool.getImageMeta(tempFile, tagList);
zipFileNameMap.forEach((k, v) -> System.out.println((k + ":" + v)));

UnspecifiedTag{name: "ZipFileName"}:SupplementaryMaterialTables_V1.docx

In the documentation it mentions that when parsing, it returns a String[], however if I try and make the map Map<Tag, String[]> it fails.


Solution

  • What's happening is that duplicates are being overridden in the Map. In order to resolve this I've created some helper classes of several methods, making Map<String, Tag> and it's now adding all files to the map.