Manipulating file dates
Chris F.A. Johnson
chris-E7bvbYbpR6jSUeElwK9/Pw at public.gmane.org
Sat Mar 27 19:19:08 UTC 2010
On Sat, 27 Mar 2010, Giles Orr wrote:
> I'll shortly be boarding a flight back to Toronto, at which time I'll
> have about a thousand photos with the wrong time stamp on them (I
> never remember to reset the camera until about five days have passed).
> All the photos have a Toronto time stamp on them, when what I need is
> six hours later. I admit I'm sitting at a Windows computer in a hotel
> and haven't attempted to research this myself, but I've looked at it
> in the past and the process was a bit confusing. As I recall, I would
> need to get the time from the file, convert to seconds since the
> computer epoch (some time in 1969?, although I think that's immaterial
> in this context?), add 6*60*60 seconds, then convert back to date
> format. Looping through the files with touch is no problem, but help
> with the date manipulation under Bash would be much appreciated.
Do you want to change the dates on the file or the date in the
file?
To change the date in the EXIF header of a jpeg, I use jhead
(there are other utilities as well).
To change the dates of the files, use touch:
touch -d "$(date -r "$file" +"%Y-%m-%d %H:%M:%S") +6hours" $file
--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list