Manipulating file dates

Giles Orr gilesorr-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Thu Apr 1 01:59:31 UTC 2010


On 30 March 2010 15:13, Renata Rocha <natzilla-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:
> On Sat, Mar 27, 2010 at 15:03, Giles Orr <gilesorr-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> 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.
>
> I'm pretty sure you won't need to change the files' date, but the jpg
> headers info.
>
> There's a command line tool named "exif" (self-describing)  which
> deals with exif headers. May be useful for what you need.

I did actually mean the file date stamp, but you're right that I
should consider the exif data.  Because of the way my local scripts
handle processing, it was important I fix the date stamp, and I've
done that with this:

for file in *.JPG; do touch -d "$(date -d @$((21600 + $(date -r
"${file}" +"%s"))) +"%Y-%m-%d %H:%M:%S")" "${file}" ; done

Which is what I mentioned in the first place: convert to seconds since
1970, add six hours (21600 seconds), nail the "@" symbol on the front
of the number so "date" will take it as a number-of-seconds value and
spit it out in a different format, and finally touch the file with
that value.

I really should change the exif data: just because I don't need it
right now isn't a good reason to leave it wrong ...

Thanks everyone for the assistance.

-- 
Giles
http://www.gilesorr.com/
gilesorr-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
--
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