My use case: Google Photos have removed the ability to save and search by tag. OneDrive Photos do have that ability to save and search tags, but since they have started charging for photos over a certain volume, right now, I want to stick with Google.
To start with, if I can prove that I can programmatically update 1 metadata element in 1 photo, in PowerShell, then everything else (searching, bulk updating) can wait until another day.
Marcel wrote his jpg metadata utility in C#, with, quite reasonably, no assembly/dll saved on Github. But let’s assume I have no C# compiler available. Well helpfully, he also made an entry on Nuget, which indirectly gives me access to the DLL.
However, natively, Nuget is not available to PowerShell. But Chocolatey hosts an implementation of Nuget, so I can run that:
choco install nuget.commandline
A quick check that we have a working Nuget:
Now, because we know that NuGet knows of the metadata utility, we can ask NuGet to install it:
NuGet.exe install Xpericode.JpegMetadata
The dll [XperiCode.JpegMetadata.dll] is concealed at the bottom level of the created folder [XperiCode.JpegMetadata.0.9.0], so find the dll, and copy it to the current folder, for ease of reference. Load the assembly:
Add-Type -Path .\XperiCode.JpegMetadata.dll
Now you have to find a test jpg from somewhere… in fact cos I’m nice you can use my one here:
Save that to a place, and then run this (adjusted for your location):
$jpg = New-Object XperiCode.JpegMetadata.JpegMetadataAdapter("c:\sandbox\powershell\BartonOnSea01.jpg")
How do I know that is the command? Because Marcel helpfully said so:
And now the money shot – the expected result from this next action is that on opening the jpeg from File Explorer, the Title element is set as requested:
$jpg.Metadata.Title = "Work, damn you, WORK!" $jpg.Save() $jpg = $null
Finally, all the key commands together:
choco install nuget.commandline NuGet.exe install Xpericode.JpegMetadata Add-Type -Path .\XperiCode.JpegMetadata.dll $jpg = New-Object XperiCode.JpegMetadata.JpegMetadataAdapter("c:\sandbox\powershell\BartonOnSea01.jpg") $jpg.Metadata.Title = "Work, damn you, WORK!" $jpg.Save() $jpg = $null