ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: txastro on February 14, 2012, 09:23:27 AM

Title: Remove space in camera temperature
Post by: txastro on February 14, 2012, 09:23:27 AM
I have tried but haven't been able to remove the space in the camera temperature (20 C to 20C).  Instead of removing the space, everything following the number is removed (20 C to 20).  I thought I probably had a typo I couldn't find, so I tried the following snippet to change spaces to underscores.


CameraTemperature2 => {
            Require => 'CameraTemperature',
            ValueConv => '$val =~ tr/ /_/; $val',
        },

Even using this everything after the number is removed.  Since the behavior is not what I was wanting, I am not even sure that the entire numeric portion remains.  On the few images I checked the numeric temperature value is correct, but I have a little over 20k images.

Am I missing something in the code?

Thanks,
Xavier
Title: Re: Remove space in camera temperature
Post by: Phil Harvey on February 14, 2012, 10:31:05 AM
Hi Xavier,

The "C" is added in the print conversion, so you can do what you want by adding the C yourself to the ValueConv value.  I would add the C in the print conversion here too, but without the space:

        ValueConv =>'$val',
        PrintConv => '"${val}C"',

This could also be done without the need for a user-defined tag:

exiftool -p "$cameratemperature#C" FILE

(use single quotes in Mac/Linux, or double quotes as above in Windows)


- Phil
Title: Re: Remove space in camera temperature
Post by: txastro on February 14, 2012, 09:59:27 PM
Thanks.  That worked great and was so simple.

Xavier