Find exif tags in image by name/value - tags

Is it possible to find and print all exif tags, contained specific word in name/value.
For example I need to find all tags, who has "Unknown" value or all "Nikon*" name tags? Will be nice to do it with exiftool.

You can't list just tags that have a specific value but you can check to see if there exists a tag with the value by checking full groups of tags. For example:
exiftool -if "$EXIF:all=~/Unknown/" -EXIF:all /path/to/files/
With that command, if one of the tags in the EXIF group contains a value that includes "Unknown", then all the EXIF tags will be displayed. You can check against the group All:All but processing will be very slow as it will check against all tags that exiftool knows, not just what is in the file, which numbers in the 10s of thousands.
You can use wildcards when listing tag names. For example, you could use -GPS* and all tags that start with GPS will be listed.

Related

Mailmerge single image into a Word Document based on a cell value

I'd like to include an image into a mail merged word document based on the presence of a single value in a column which contains several values.
e.g. if the cell contains the value BOB insert image, if it contains any other value then do nothing.
Most of the {INCLUDEPICTURE} functionality seems built around including a different image based on a filename matching a cell value.
{INCLUDEPICTURE} "MERGEFIELD Selection_identifier).png"\*
MERGEFORMAT \d }
Works provided I translate selection_identifer in the spreadsheet itself, but there has to be a better way. There seems to be little information about this particular usecase online.
If you are only using a single image and it does not vary between merges, you should probably just use
{ IF "{ MERGEFIELD Selection_identifier }" = "BOB" "<the_image>" }
where <the_image> is a copy of the actual image, sized how you want, pasted between those quotation marks. In that case, there would be no need for an INCLUDEPICTURE field or a reference to an external image file.
As usual, all the {} have to be the special field code brace pairs that you can insert on Windows Desktop Word using Carl-F9 or similar.

Use Exiftools to add a tag with spaces and special characters to an image file

When I compare a file that uploads correctly (into Mapillary) and a jpg file that fails in EXIFTOOLS I see that it doesn't have Create Date, Date/Time Original and Modify Date. There are lots of other fields as well but these are the only ones dealing with time.
When I try to use
'.\exiftool(-k).exe' -"Date/Time Original"="2019:10:27 18:14:10.5" Photo_2019_Jul_12_13_38_40_019.jpg
It doesn't let me add the tag (I assume) because it has a '/' in it. It also doesn't allow "Create Date" for example.
How can I create a tag with these?
Some sample files are in https://drive.google.com/drive/folders/1QCQdSvdk0RygfCqqRWaOj-IzBbj17gax?usp=sharing
See ExifTool FAQ #2
"Date/Time Original" isn't the tag name, it's the tag description, which can change depending upon the set language (see the -lang option). Tag names don't have spaces or special characters. The actual tag name to set a value is DateTimeOriginal.
So your command should be
.\exiftool(-k).exe -DateTimeOriginal="2019:10:27 18:14:10.5" Photo_2019_Jul_12_13_38_40_019.jpg
Though take note that DateTimeOriginal doesn't hold a subsecond value. The location for that would be SubSecTimeOriginal. But exiftool does have a shortcut. If you set SubSecDateTimeOriginal, it will set the DateTimeOriginal and SubSecTimeOriginal tags. Also, if you add a time zone to the end of that, it will set OffsetTimeOriginal, where the time zone value is held.
For example:
.\exiftool(-k).exe -SubSecDateTimeOriginal="2019:10:27 18:14:10.5-04:00" Photo_2019_Jul_12_13_38_40_019.jpg

Exiftool - modify metadata format

Suppose I have 5000 images with following metadata in the LABEL field.
0001 ELEPHANT
0002 ELEPHANT
0003 ELEPHANT
...
4999 ELEPHANT
5000 ELEPHANT
I wish to change the format to:
ELEPHANT-0001
ELEPHANT-0002
ELEPHANT-0003
…
ELEPHANT-4999
ELEPHANT-5000
In other words, I want to do the following for a metadata field of multiple images:
#### NAME —> NAME-####
From what I can gather there could be two ways of doing this
Ignore the current metadata in the images, and reference a (plain text? csv?) file that I prepare separately; or
Read the file's metadata as a string, identify the space and the number preceding the space, save that number, and finally make a new string by concatenating the number and space, and adding a hyphen in between!
Any suggestions?
Expanding upon the answer I gave in the exiftool forums.
The basic command would be
exiftool "-LABEL<${LABEL;s/(\d{4}) (.*)/$2-$1/}" <FileOrDir>
You basically want to copy a tag into the same tag, with some modifications. The option to copy a tag is the less than (or greater than) symbol < or >. A common mistake is to use the equal sign = which is used to assign a static value to a tag.
To do the modification to the tag, it takes the Advance Formatting option, which is actually some in-line perl code. In this example, the tag is treated as a perl string and a regex substitution is used. It matches and captures the first four digits (\d{4}), matches the space (but doesn't capture it), then matches and captures the rest of the tag (.*). The two captures are assigned to the variables $1 and $2, respectively. In the replace half of the substitution $2-$1, the two captures are reversed with the hyphen between them.
To take full advantage of the advance formatting, some basic perl and regex knowledge is helpful.
Once you are sure of the command, you can add -overwrite_original to suppress the generation of backup files and -r to recurse into subdirectories.

Manipulate status of links in Word document with OpenXML SDK

I have a Word-Document with some links to cells in Excel-files. In Word, I can get a context menu, that leads to a window with all the links of the document. There, I can see and manipulate properties of the links.
Amongst others, there is the part "Updatemethod for chosen link" (words may differ, I translated it from the German version), I have two radio-boxes with "automatic" / "manual". And a Checkbox "locked".
I want to modify (especially the locked-checkbox) these properties with OpenXML, but I did not find the place, where in the model this information is stored. I printed the OuterXML for a link with locked checked and for a link with locked unchecked, but did not find any differences in the parameter field (\a \f 5 \h * MERGEFORMAT - for both!)
Anyone knows, how I can modify this with OpenXML SDK?
Thanks in advance,
Frank
Word has different ways to represent the LINK in Office Open XML depending partly on the format of the link (e.g. whether you Paste Link to an object or to plain text).
For example, if you paste a link to a "Microsoft Excel Worksheet Object", although Word displays a LINK field in the document, the XML does not actually record the field code using either the simple or more complex encoding for field codes. It actually encodes the object in a <w:object> element that records information about a "shape", with the shape type in <v:shapetype>, the shape itself in <v:shape>, and information about the OLE link in <o:OLEObject>
In that case, Automatic link updating is recorded using
<o:OLEObject UpdateMode='Always'> for automatic links
and
<o:OLEObject UpdateMode='OnCall'> for manual links.
Whether or not the link is Locked is recorded in
<o:OLEObject><o:LockedField></o:LockedField<o:OLEObject>
(either as "false" or "" AFAICS).
Word reconstructs the LINK field code from the w:object information when it displays the document.
However, if you paste the link as text, the XML Word records will contain a complex field code construction, starting with a <w:fldChar w:fldCharType='begin' /> element.
In that case, the fact that the link is locked is indicated by a value of '1" in the w:fldLock attribute, and probably the absence of that attribute if it is not locked. e.g.
<w:fldChar w:fldCharType='begin' w:fldLock='1' />
In either case, an automatic link is indicated by the presence of the \a switch in the field code (reconstructed in the case of the first example). If there is no \a switch, it's not an automatic link.
That may not cover all the possible cases but should give you some clues about where to look in the XML.

How can I identify an OpenXml Paragraph as one I programmatically inserted?

I am programmatically adding an OpenXML paragraph to a Word Document and I need to be able to identify that paragraph as mine later on. Any ideas on how to do this? I have tried inserting an XML comment and extended attributes but when you save the document in word it removes all unknown xml. It doesn't matter if it is an attribute in the paragraph or the run, or an element before the paragraph, just some way I can identify it later on. Also, I do not want this identifier visible in the word document.
Examples of what I could use:
<paragraph id="myParagraph"></paragraph>
<otherelement>myparagraph</otherelement>
<paragraph></paragraph>
Any help would be AWESOME because my head it hurting from the brick wall I have been running into.
Thanks!
Give the paragraph a w:rsidR attribute and assign a unique value to it; if there is no value present when word saves the document it will randomly assign it's own 8-digit hexadecimal value anyway. (The value is not limited to 8 digits or hexadecimal characters. Word will not modify existing RSIDs.)
That being said -- make sure to keep RSID values unique and do NOT modify existing RSID attributes -- they are the unique ID for that paragraph, and if the document splits into multiple versions and a user tries to merge them back together those RSIDs are used to determine what paragraphs have changed.
(Also note that runs have RSIDs as well.)
If the user modifies the paragraph, the RSID of that paragraph may change.
The alternate option is to use Custom XML: http://msdn.microsoft.com/en-us/library/bb608618.aspx
Use stylename in paragraph properties.
or try this one
http://msdn.microsoft.com/en-us/library/office/hh674468.aspx
Hope this helps.