[SOLUTION] Exiftool and Japanese Characters

Started by wtuemura, April 08, 2024, 09:01:25 PM

Previous topic - Next topic

wtuemura

I was trying to use the command prompt (Windows 10) to dump some flac metadata from files with Japanese characters without success, after finding this solution here I could not get exiftool to write the output with the -textOut option. This is solved by doing the following:

  • Open the command prompt, set it to Shift-JIS with command mode con cp select=932
  • Pipe the file to exiftool and redirect the output to a text file, use quotes when your filename has spaces, ex: type "01. 電撃戦隊チェンジマン.flac" | bin\exiftool - > "01. 電撃戦隊チェンジマン.txt" 2>&1

Now you should have a text file with all the metadata you need. I don't want to repeat this process manually over and over again when I need to dump metadata from hundreds of files, so I developed this batch script, create a folder to store this script, create another folder named bin and unzip the exiftool binaries into it, name the script dump-japanese-metadata.bat outside the bin folder:

REM dump-japanese-metadata.bat
REM Created by wtuemura 04/08/2024
REM CC by 4.0
REM Drag and drop the file over this script.

@echo off

setlocal
REM setlocal EnableDelayedExpansion
REM set the command prompt to Japanese (Shift-JIS)
mode con cp select=932
cls

Title Export meta information to text files

if exist %~dp0\bin\exiftool.exe (

set EXIFTOOL=%~dp0\bin\exiftool.exe
set EXIFTOOL_CONFIG=

) else (
  echo Could not find exiftool!
  echo Download from https://exiftool.org
  echo.
  pause
  echo Ending...
  goto :end
)

for %%A in (%*) do type %%A | %EXIFTOOL% - %EXIFTOOL_CONFIG% > "%%~nA.txt" 2>&1

:end
endlocal
exit /B

Now when I drag my Japanese files over the script, it dumps the metadata with the same filename, but in text format.

More related info:
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chcp
https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers