ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: ericconn on July 31, 2024, 02:27:20 PM

Title: Reverting a field (SerialNumber) to null
Post by: ericconn on July 31, 2024, 02:27:20 PM
I have some SerialNumber fields in JPG's that were converted into spaces and would like to revert them to null. When using exiftool -SerialNumber= (filepath) they don't truly revert to null, as when I write the files metadata to CSV and use -f the field is a blank cell in Excel, and not a "-" like it should be when using -f.

Thanks.
Title: Re: Reverting a field (SerialNumber) to null
Post by: Phil Harvey on July 31, 2024, 03:17:23 PM
This is the format to write an empty tag:

exiftool -serialnumber^= FILE

- Phil
Title: Re: Reverting a field (SerialNumber) to null
Post by: StarGeek on July 31, 2024, 04:20:00 PM
Quote from: Phil Harvey on July 31, 2024, 03:17:23 PMexiftool -serialnumber^= FILE

On Windows CMD, you would have to use this, because the Caret ^ is a special character in CMD.
exiftool "-serialnumber^=" FILE
Title: Re: Reverting a field (SerialNumber) to null
Post by: ericconn on July 31, 2024, 05:34:57 PM
Thanks. That still yields a blank but not null field for me.

SourceFile   SerialNumber
D:/file.jpg   
Title: Re: Reverting a field (SerialNumber) to null
Post by: StarGeek on July 31, 2024, 07:22:57 PM
Then your first command is what you want to use. But there is a caveat.  Some SerialNumber tags cannot be removed.

For example, in this file, the Canon:SerialNumber cannot be removed or cleared. It can only be set to a number. In the first command, I removed the EXIF:SerialNumber, but not the Canon:SerialNumber.  It then explicitly try to clear it. Then try to set it to a 0 length string, i.e. it exists but has an empty value. I try again with the hashtag shortcut for the -n (--printConv) option (https://exiftool.org/exiftool_pod.html#n---printConv). The best I can do is set it to 0.
C:\>exiftool -G1 -a -s -serialnumber Y:\!temp\Test_CR2.Cr2
[Canon]         SerialNumber                    : 1470912081
[ExifIFD]       SerialNumber                    : 1470912081

C:\>exiftool -P -overwrite_original -SerialNumber= Y:\!temp\Test_CR2.Cr2
    1 image files updated

C:\>exiftool -G1 -a -s -serialnumber Y:\!temp\Test_CR2.Cr2
[Canon]         SerialNumber                    : 1470912081

C:\>exiftool -P -overwrite_original -Canon:SerialNumber= Y:\!temp\Test_CR2.Cr2
Warning: Can't delete Permanent tag Canon:SerialNumber
Nothing to do.

C:\>exiftool -P -overwrite_original "-Canon:SerialNumber^=" Y:\!temp\Test_CR2.Cr2
Warning: Not an integer for Canon:SerialNumber
Nothing to do.

C:\>exiftool -P -overwrite_original -Canon:SerialNumber#= Y:\!temp\Test_CR2.Cr2
Warning: Can't delete Permanent tag Canon:SerialNumber
Nothing to do.

C:\>exiftool -P -overwrite_original -Canon:SerialNumber=0 Y:\!temp\Test_CR2.Cr2
    1 image files updated

C:\>exiftool -G1 -a -s -serialnumber Y:\!temp\Test_CR2.Cr2
[Canon]         SerialNumber                    : 0000000000