Circular - Update Extension and Meta Data

Started by grimacing-visor, February 08, 2023, 08:56:49 AM

Previous topic - Next topic

grimacing-visor

I'm trying to deal with some Apple screenshots that are being saved as PNG but the metadata is image/jpeg.

exiftool steps in to save the day with clearing up the extension mess with:

exiftool "-filename<%f.$fileTypeExtension" -ext PNG IMG_REALLY_JPG.PNG
but there is no date meta data in the image and the rewrite loses the only date that makes any sense which is FileModifyDate.  I tried to get fancy with the following but I think it's too circular:

exiftool "-filename<%f.$fileTypeExtension" "-DateTimeOriginal<FileModifyDate" -if 'not $datetimeoriginal' -ext PNG IMG_REALLY_JPG.PNG
Error: Not a valid PNG (looks more like a JPEG) - IMG_PNG_TEST.PNG
    0 image files updated
    1 files weren't updated due to errors

Any tips on correcting the PNG files to jpeg (if applicable) and add the original FileModifyDate if one is missing?

Phil Harvey

Just renaming the file doesn't change the FileModifyDate on Mac or Linux.  I really hate it when someone makes me fire up my Windows virtual machine, but I tested this and it is true for Windows too.

The FileModifyDate will only change if you actually make a change to the data in the file without using the -P option.

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

grimacing-visor

Thanks for the quick reply Phil.  No need for the VM this is on a Mac.  Let me triple check the dates on my end.  I gather that the command should work then.

Update: You're correct, FileModifyDate didn't change, the other dates did.  False alarm.

Phil Harvey

If you are on Mac, you should be using single quotes around arguments containing a "$".

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