LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Batch: Stripping EXIF metadata + Preserving of the original date (http://www.linuxquestions.org/questions/linux-general-1/batch-stripping-exif-metadata-preserving-of-the-original-date-864559/)

Tryum 02-23-2011 10:59 AM

Batch: Stripping EXIF metadata + Preserving of the original date
 
I would like to remove almost all of the Privacy Evading data that a digital camera is generating, such as EXIF DATA.
EXIF DATA: Camera Brand, Camera Model, Date taken, Exposure Time, Flash Fired, Focal Length, Location (if you are using iPhone with categorization by location, if enabled), Metering Mode, etc.

May you, please, write a script which does that job for multiple files?

Exiv2 seem to reduce more weight than Jhead so I'll use the command exiv2.

That's, generally, what I want the script to do:
  • Retrieve the (Modified) date of a file:
    Code:

    $ date -r FILE_NAME
    Output:
    Code:

    Thu Feb  3 20:55:12 IST 2011
  • Remove EXIF metadata from a file:
    Code:

    $ exiv2 rm FILE_NAME
  • Modify the (Modified) date of a file:
    Code:

    $ touch -d 'Thu Feb  3 20:55:12 IST 2011' FILE_NAME

someshpr 02-24-2011 09:02 AM

Hi,
If I understand you correctly, you want to remove all exif info from the file while preserving the original date of the file; and you have figured out a way to do that for one file and want to batch process all the files using a script.

Assuming that your directory contains only files that you want to touch-up, this can be a way batch process them for the commands you have listed.

Code:

#!/bin/bash
cd your-direcotry
for file in `ls`; do
        DATE=`date -r $file`
        exiv2 rm $file
        touch -d $DATE $file
done

HTH,

crts 02-24-2011 09:39 AM

Quote:

Originally Posted by someshpr (Post 4269688)
Hi,
If I understand you correctly, you want to remove all exif info from the file while preserving the original date of the file; and you have figured out a way to do that for one file and want to batch process all the files using a script.

Assuming that your directory contains only files that you want to touch-up, this can be a way batch process them for the commands you have listed.

Code:

#!/bin/bash
cd your-direcotry
for file in `ls`; do
        DATE=`date -r $file`
        exiv2 rm $file
        touch -d $DATE $file
done

HTH,

Hi,

have a look here
http://mywiki.wooledge.org/BashPitfa...8ls_.2A.mp3.29
http://mywiki.wooledge.org/BashFAQ/082

why the output of ls should not be parsed and why $() is preferred over `backticks`.
So based on someshpr's solution some minor modifications:
Code:

#!/bin/bash
cd /path/to/your/directory/
for file in *; do
        DATE=$(date -r "$file")
        exiv2 rm "$file"
        touch -d "$DATE" "$file"
done

@OP: I am not familiar with exiv2, so I assume that the commands provided do what you want.

Tryum 02-24-2011 12:45 PM

Thank you all for your, absolutely, important help!

It is exactly what I wanted.
And, of course, it is touching files without EXIF metadata within them, but it really does not matter (who cares, as long as the original modification date is the same, right?!). ;P

For the record: If you are reading this post and want to improve it to make it to work with GUI dialog box (Python or Zenity etc.) you might want to clone the following application (Windows)
The Portable Freeware Collection - JPEG & PNG Stripper
JPEG & PNG Stripper - www.SteelBytes.com


All times are GMT -5. The time now is 09:23 PM.