LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-23-2011, 10:59 AM   #1
Tryum
LQ Newbie
 
Registered: Oct 2010
Distribution: Zenwalk
Posts: 19

Rep: Reputation: 0
Question 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

Last edited by Tryum; 02-23-2011 at 11:04 AM.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-24-2011, 09:02 AM   #2
someshpr
Member
 
Registered: Jul 2009
Location: CA, USA
Distribution: Debian, RHEL5.4, CentOS 5.4, 6.2, Ubuntu 11.04,12.04
Posts: 107

Rep: Reputation: 26
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,
 
Old 02-24-2011, 09:39 AM   #3
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,604

Rep: Reputation: 446Reputation: 446Reputation: 446Reputation: 446Reputation: 446
Quote:
Originally Posted by someshpr View Post
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.
 
2 members found this post helpful.
Old 02-24-2011, 12:45 PM   #4
Tryum
LQ Newbie
 
Registered: Oct 2010
Distribution: Zenwalk
Posts: 19

Original Poster
Rep: Reputation: 0
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
 
  


Reply

Tags
batch, exif, metadata


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
search recursively by exif date? rioguia Programming 6 02-21-2010 05:49 AM
Sorting photos into folders based on exif date SuperJediWombat! Programming 7 05-16-2009 06:53 PM
Preserving date and ownership when untar ? talat Linux - Software 1 02-09-2006 04:07 PM
need software to batch-rotate jpeg's based on exif data mfcarroll Linux - Software 3 03-07-2005 02:39 PM
Any programs to rename a image to it's EXIF date ? CRego3D Linux - Software 1 11-08-2004 02:25 PM


All times are GMT -5. The time now is 12:08 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration