Search code examples
tagsjpegphotoshopphotoexif

How to remove all EXIF informations without changing file date (modified date)?


I have some JPEG photos with many EXIF / tag informations.

I want to remove all EXIF information without changing the date of the file (modified date). Do you know how to do that ?

I'm on macOS Sierra and I know some terminal commands. (the problem is that some soft like ExifPurge change the modified date).

Thanks !


Solution

  • You can get the file modification date with:

    GetFileInfo -m image.jpg
    08/29/2017 13:04:05
    

    So, if you want to save it in a variable called saved:

    saved=$(GetFileInfo -m image.jpg)
    

    Now, do your EXIF removal...

    And set the date back to what it was with:

    SetFile -m "$saved" image.jpg
    

    Not sure what tools you use to delete EXIF data, but last time I checked, if you use jhead, it doesn't change the modification time:

    jhead -de image.jpg
    

    If that is the case, all the previous part of this answer is not needed. So, maybe try using jhead with a copy of just a few of your files in a separate test directory like this:

    jhead -de *.jpg
    

    If that doesn't do what you want, you'll need to make a little script that does all the files in a directory using the method above. That will look something like this:

    #!/bin/bash
    shopt -s nullglob
    
    for f in *.jpg; do
       echo Processing file: $f
    
       # Save modification date
       saved=$(GetFileInfo -m "$f")
    
       # DO YOUR EXIF REMOVAL ON FILE "$f" HERE
    
       # Reset date
       SetFile -m "$saved" "$f"
    done