[Nottingham] Bash - extract date and time from jpg file

Alex Walker alex at x3ja.co.uk
Wed Feb 25 14:10:19 UTC 2009


The command "exiftags" would be useful here - you may need to install it
first though of course - it's in Debian at least. It gives output like
this:

Equipment Make: Canon
Camera Model: Canon PowerShot A70
Maximum Lens Aperture: f/2.8
Sensing Method: One-Chip Color Area

Image-Specific Properties:

Horizontal Resolution: 180 dpi
Vertical Resolution: 180 dpi
Image Created: 2005:08:17 07:48:29
Rendering: Normal
Exposure Mode: Auto
White Balance: Auto
Scene Capture Type: Standard
Exposure Time: 1/800 sec
F-Number: f/2.8
Lens Aperture: f/2.8
Exposure Bias: 0 EV
Metering Mode: Pattern
Flash: No Flash, Auto
Focal Length: 5.41 mm
Color Space Information: sRGB
Image Width: 1536
Image Height: 2048
Image Number: 112-1264

So you should be able to grab what you need from that along the lines of:

for f in *.jpg
do
	mv $f `exiftags $f  2> /dev/null |grep "Image Created" | sed -e 's/Image Created: //' -e 's/ /\_/g'`.jpg
done

That'd rename all jpg files in the folder to just be names as per their Image Created value... so probably wants tweaking depending on what you want.

Hope that helps!

Alex

On Wed, Feb 25, 2009 at 01:49:26PM +0000, Ron Wilton wrote:
> Thanks to all who answered my last email about where to put bash files. In the end I realised that I forgot to put 'bash' in before the file name on the command line!

> I do have another question.

> Is it possible to use bash to extract the date and time from a JPG file so that I can rename that file with this information?

> Thanks

> Ron

> _______________________________________________
> Nottingham mailing list
> Nottingham at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/nottingham

-- 
Randomly generated quote:
blithwapping:
	Using anything BUT a hammer to hammer a nail into the
	wall, such as shoes, lamp bases, doorstops, etc.
		-- "Sniglets", Rich Hall & Friends



More information about the Nottingham mailing list