Show coordinates with ° symbol

Started by elhiero, March 27, 2025, 11:28:16 AM

Previous topic - Next topic

elhiero

Sometimes, i need to get coordinates with this format :
45°43'54.0"N 4°49'03.9"E

- I can write metadata with -E
"-E -iptc:caption-abstract=45°C" file01.jpg
But I need to use the ° character in a format string ...
I tried some -p and -c formats, and I couldn't find a solution ...
like  ${GPSLatitude;s/deg/°/}

Thanks in advance




Phil Harvey

Try using the -c option to specify the coordinate format.

On Mac/Linux it could look like this:

exiftool -c "%d°%d'"'%.1f"' ...

But the quoting is tricky and it would be different in Windows.

- 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 ($).

elhiero

C:\>chcp 65001
Page de codes active : 65001

CaptionAbstract = 20°5 is shown
C:\>exiftool  -p "$Caption-Abstract, $GPSLatitude, $GPSLongitude" "C:\\test02.jpg"
20°5, 45 deg 10' 48.00" N, 5 deg 43' 12.00" E

-c option, the ° character is ignored
C:\>exiftool  -p "$Caption-Abstract, $GPSLatitude, $GPSLongitude" -c "%d° %d' %.2f\"" "C:\\test02.jpg"
20°5, 45 10' 48.00" N, 5 43' 12.00" E

-c option, the * character is displayed
C:\>exiftool  -p "$Caption-Abstract, $GPSLatitude, $GPSLongitude" -c "%d* %d' %.2f\"" "C:\\test02.jpg"
20°5, 45* 10' 48.00" N, 5* 43' 12.00" E

-p option : '@' character can replace ' deg'
C:\>exiftool  -p "$Caption-Abstract, ${GPSLatitude;s/ deg/@/}, $GPSLongitude" "C:\\test02.jpg"
20°5, 45@ 10' 48.00" N, 5 deg 43' 12.00" E

... but ° character cannot replace ' deg'
C:\>exiftool  -p "$Caption-Abstract, ${GPSLatitude;s/ deg/°/}, $GPSLongitude" "C:\\test02.jpg"
20°5, 45  10' 48.00" N, 5 deg 43' 12.00" E

Phil Harvey

What shell are you using?  CMD or PS or something else?

Can you echo a ° character to the console using the system echo command?:

echo °

- 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 ($).

elhiero

I use cmd, with Windows10
exiftool 13.25 64.zip

- Yes echo ° displays °

I also tried codepage 850, but then CaptionAbstract does not show 20.5° but 20.5 with a square character.
Charset has no effect on -c string

On windows 7 , it's worst, with chcp 65001,  sometimes cmd hangs or close itself when I copy the exiftool command containing °, before I can use Enter key ...

I can also try win11 later

Phil Harvey

Did you try the "echo" command?

- 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 ($).

elhiero

My message was edited while you were replying ...
... because your previous question was edited while i was replying  ;D   ;D

Yes echo ° displays °

Phil Harvey

Ah yes... dueling edits. :P

I can't understand why the echo command would work and it doesn't work in ExifTool. :(

what about these intermediate steps?:

1. exiftool -echo °

2. exiftool -p ° FILE

3. exiftool -p "°" FILE

- 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 ($).

elhiero

None of these instructions can display °

C:\>exiftool -p "&#{[a|^à+£$°²" test02.jpg
&#{[a|^+$

cannot display ² £ ° à and maybe some others?
it seems that these characters belong to a special family ...
-charset option has no effect

cmd:
C:\>echo "&#{[a|^à+£$°²"
"&#{[a|^à+£$°²"
all characters are displayed

Phil Harvey

OK, you forced me to fire up the Windows virtual machine to test this out.

Even though I couldn't figure out how to generate a ° symbol in the Windows CMD window, I was able to reproduce the issue with a happy face.  Wow, Windows special characters are really messed up.  I don't know what translation is happening, but the character gets changed somehow before ExifTool gets it.  The workaround I was able to get working was to create a UTF-8 text file (args.txt) with these two lines:

-c
%d°%d'%.1f"

Then use this command:

exiftool -@ args.txt ...

This should display correctly if you are using chcp 65001 in the cmd window.

- 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 ($).

FrankB

+1 for me, for using an args file saved as UTF-8.

Ever since I changed that in ExifToolGUI there are no more 'international character' issues, that I'm aware of. And yes for displaying you need CHCP 65001.

Background: Apparently the CMD shell always translates the command line parameters to 'something not UTF-8'.

Phil Harvey

Quote from: FrankB on March 28, 2025, 08:14:11 AMApparently the CMD shell always translates the command line parameters to 'something not UTF-8'.

But I don't understand why the "echo" command works. :/

- 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 ($).

FrankB

I haven't got the (definitive) answer. But there is a difference.

Echo is an internal command in cmd.exe. You will not find echo.com or echo.exe. So Cmd.exe doesn't need to start an external program, like exiftool.exe.

https://ss64.com/nt/echo.html

If the matter interests you, I can dig deeper. For now the solution is to use an ARGS file.

Frank

Phil Harvey

Hi Frank,

Thanks.  Your explanation makes sense.  No need to dig deeper.

- 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 ($).