JSON output filenames do not appear to be in the same encoding as the @ input

Started by CCC, December 27, 2023, 01:07:32 PM

Previous topic - Next topic

CCC

Hi

In the following example, the input filename starts with Jürgen, yet the JSON output has it displayed as J├╝rg. I've tried various encoding options with no luck. Using PowerShell on Windows 11.

Any suggestions to have the input and json output file be the same.

Thanks,


files.txt == Jürgen Lobert - Astro-Landscapes JL71509-Edit-1.jpg


PS C:\Temp\test\neccc> \\STORAGE\Scripts\exiftool.exe -charset UTF8 -charset filename=UTF8 -@ files.txt -j -filename
[{
  "SourceFile": "J├╝rgen Lobert - Astro-Landscapes JL71509-Edit-1.jpg",
  "FileName": "J├╝rgen Lobert - Astro-Landscapes JL71509-Edit-1.jpg"
}]
PS C:\Temp\test\neccc> dir


    Directory: C:\Temp\test\neccc


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        12/27/2023  11:21 AM             52 files.txt
-a----        12/27/2023  12:45 PM             52 foo2.txt
-a----        12/30/2018   8:45 PM        1889784 Jürgen Lobert - Astro-Landscapes JL71509-Edit-1.jpg




p.s. great tool, thank you!


Phil Harvey

JSON is encoded in UTF-8.  To view special characters properly you need to set your terminal to UTF-8.  FAQ 18 may help with this.

If you can't get this to work, send the output to a file and open the file in a UTF-8 text editor:

exiftool.exe -charset UTF8 -charset filename=UTF8 -@ files.txt -j -filename > out.json

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

CCC

Thanks for the tips. I keep the output within PowerShell. I started saving the output from EXIF when PowerShell said that 'SourceFile' in the JSON did not exist when using if (!(Test-Path -LiteralPath <on the SourceFile)) . Let me do a more checking.

$MetaDataInfoAsJSONText = &$ExifToolPathname -d "%Y-%m-%dT%H:%M:%S" -charset UTF8 -charset filename=UTF8 -b "-@" "$($ExifToolCommandFile)" -j -rights -datetimeoriginal -FileModifyDate "-FileSize#" -model -description -LensModel -Location -City -State -Country -CountryCode -Title -keywords -ImageWidth -ImageHeight -Aperture -ShutterSpeed -ISO -Rating -Label -ExposureProgram -charset exif=utf8 -charset iptc=utf8 | Out-String

StarGeek

One thing to watch for is that you're piping data in PowerShell. Powershell can corrupt piped/redirected data.  It usually will be binary data that gets corrupted, but some higher value UTF characters might also have problems.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).