Fixing file mod dates

Discussion in 'NZ Computing' started by Lawrence D'Oliveiro, Oct 27, 2008.

  1. I copied some photos off an xD card for my Fujifilm camera, and then
    discovered that the camera's clock had fallen behind the correct time by
    some 4 minutes. (It regularly seems to drift by about a minute a week.)

    I guess I'm a bit anal about making sure that my files have the right
    date/timestamps on them. Here's how I fixed the dates on the photo files.

    First of all, the usual command for fiddling file dates is called "touch".
    This can set a file's last-modified date using a command of the form

    touch <file> -t YYYYMMDDhhmm.ss

    Producing the timestamp in the right format is of course a job for
    the "date" command. If the file's existing last-mod date/time is
    <last-mod>, then a corrected date/time can be output in the right format by
    using

    date -d "<last-mod> + 240 seconds" +"%Y%m%d%H%M.%S"

    So how to get the file's existing last-mod date/time in the right format? I
    used

    ls -l --time-style="+%d-%b-%Y %H:%M:%SZ" <file>

    which outputs a number of unneeded columns (why doesn't ls offer, like ps,
    the option to output precisely the columns you want?). So I pick the
    precise ones I want using

    ls -l --time-style="+%d-%b-%Y %H:%M:%SZ" <file> | cut -d' ' -f6-7

    (Note the Z on the end of the output time to indicate UTC, which I used
    throughout just to keep things consistent.)

    Putting it all together, the final command line was

    export TZ=UTC; for f in *.jpg; do ls -l --time-style=full-iso $f;
    t=$(ls -l --time-style="+%d-%b-%Y %H:%M:%SZ" $f | cut -d' ' -f6-7);
    touch $f -t "$(date -d "$t + 240 seconds" +"%Y%m%d%H%M.%S")"; done

    Note the initial "export TZ=UTC" to ensure all dates/times are UTC. And the
    initial "ls -l --time-style=full-iso $f" to show the last-mod date/time
    before it gets modified. After running the above, I did

    ls -l --time-style=full-iso

    to confirm that the timestamps had been updated correctly.
    Lawrence D'Oliveiro, Oct 27, 2008
    #1
    1. Advertising

  2. In message <>, ChrisOD wrote:

    > But that doesn't fix the exif timestamp in the jpeg


    Yeah, point. Looks like libexif can do it
    <http://sourceforge.net/projects/libexif>, not sure if there's any easy
    command-line way of changing those dates/times.
    Lawrence D'Oliveiro, Oct 27, 2008
    #2
    1. Advertising

  3. By the way, did you really feel the need to quote my entire posting back at
    me, just to add one line?

    Netiquette, and all that...
    Lawrence D'Oliveiro, Oct 27, 2008
    #3
  4. In message <>, John Potter wrote:

    > On Mon, 27 Oct 2008 17:57:59 +1300, Lawrence D'Oliveiro
    > <_zealand> wrote:
    >
    >>I copied some photos off an xD card for my Fujifilm camera, and then
    >>discovered that the camera's clock had fallen behind the correct time by
    >>some 4 minutes. (It regularly seems to drift by about a minute a week.)
    >>
    >>I guess I'm a bit anal about making sure that my files have the right
    >>date/timestamps on them. Here's how I fixed the dates on the photo files.

    >
    > I use ZTree for that kind of thing.


    Hmm, can't see any option to add 4 minutes to the timestamps of a bunch of
    files.
    Lawrence D'Oliveiro, Oct 27, 2008
    #4
  5. Lawrence D'Oliveiro

    Enkidu Guest

    Lawrence D'Oliveiro wrote:
    >
    > I copied some photos off an xD card for my Fujifilm camera, and then
    > discovered that the camera's clock had fallen behind the correct time by
    > some 4 minutes. (It regularly seems to drift by about a minute a week.)
    >
    > I guess I'm a bit anal about making sure that my files have the right
    > date/timestamps on them. Here's how I fixed the dates on the photo files.
    >

    Why? What possible difference could a time stamp error of 4 minutes make?

    Cheers,

    Cliff

    --

    Tax is not theft.
    Enkidu, Oct 27, 2008
    #5
  6. Lawrence D'Oliveiro

    ~misfit~ Guest

    Somewhere on teh intarwebs "Enkidu" typed:
    > Lawrence D'Oliveiro wrote:
    >>
    >> I copied some photos off an xD card for my Fujifilm camera, and then
    >> discovered that the camera's clock had fallen behind the correct
    >> time by some 4 minutes. (It regularly seems to drift by about a
    >> minute a week.) I guess I'm a bit anal about making sure that my files
    >> have the right
    >> date/timestamps on them. Here's how I fixed the dates on the photo
    >> files.

    > Why? What possible difference could a time stamp error of 4 minutes
    > make?


    Like he said, he's "anal".


    However that prompted me to check my Canon PowerShot A70. It was 16 minutes
    fast after 4+ years and god knows how many times it's sat with flat
    batteries (NiMH, now using the LSD variety).

    I agree, 4 minutes is no big deal unless the pics are going to be used as
    evidence. Even then the clock could be changed...

    I *do* rely on the /date/ stamp on mine though for pics of my garden as it
    develops. (Pics can sit on my camera for a long time, it has a bigger
    storage card than was envisaged when the camera came out and, even on
    "superfine", stores over 1K pics.)

    Cheers,
    --
    Shaun.

    DISCLAIMER: If you find a posting or message from me
    offensive, inappropriate, or disruptive, please ignore it.
    If you don't know how to ignore a posting, complain to
    me and I will be only too happy to demonstrate... ;-)
    ~misfit~, Oct 27, 2008
    #6
  7. Lawrence D'Oliveiro

    ~misfit~ Guest

    Somewhere on teh intarwebs "Collector€NZ" typed:
    > ~misfit~ wrote:
    >> Somewhere on teh intarwebs "Enkidu" typed:
    >>> Lawrence D'Oliveiro wrote:
    >>>> I copied some photos off an xD card for my Fujifilm camera, and
    >>>> then discovered that the camera's clock had fallen behind the
    >>>> correct time by some 4 minutes. (It regularly seems to drift by about a
    >>>> minute a week.) I guess I'm a bit anal about making sure that my
    >>>> files have the right
    >>>> date/timestamps on them. Here's how I fixed the dates on the photo
    >>>> files.
    >>> Why? What possible difference could a time stamp error of 4 minutes
    >>> make?

    >>
    >> Like he said, he's "anal".
    >>
    >>
    >> However that prompted me to check my Canon PowerShot A70. It was 16
    >> minutes fast after 4+ years and god knows how many times it's sat
    >> with flat batteries (NiMH, now using the LSD variety).
    >>
    >> I agree, 4 minutes is no big deal unless the pics are going to be
    >> used as evidence. Even then the clock could be changed...
    >>
    >> I *do* rely on the /date/ stamp on mine though for pics of my garden
    >> as it develops. (Pics can sit on my camera for a long time, it has a
    >> bigger storage card than was envisaged when the camera came out and,
    >> even on "superfine", stores over 1K pics.)
    >>

    > If he is anal I am overly so, it matters to me big time that the
    > date/time stamp on my photos is correct since I set it to the time of
    > the GPS logger I carry and have software that tags the Exif in the
    > photos with the Lat/Long of where I took it.


    That's pretty cool!

    However Lawrence offered no such reason for wanting his time to be shown
    correctly other than saying "I guess I'm a bit anal". I was only quoting his
    own words.

    Cheers,
    --
    Shaun.

    DISCLAIMER: If you find a posting or message from me
    offensive, inappropriate, or disruptive, please ignore it.
    If you don't know how to ignore a posting, complain to
    me and I will be only too happy to demonstrate... ;-)
    ~misfit~, Oct 28, 2008
    #7
  8. Lawrence D'Oliveiro

    ~misfit~ Guest

    Somewhere on teh intarwebs "Collector€NZ" typed:
    > ~misfit~ wrote:
    >> Somewhere on teh intarwebs "Collector€NZ" typed:
    >>> ~misfit~ wrote:
    >>>> Somewhere on teh intarwebs "Enkidu" typed:
    >>>>> Lawrence D'Oliveiro wrote:
    >>>>>> I copied some photos off an xD card for my Fujifilm camera, and
    >>>>>> then discovered that the camera's clock had fallen behind the
    >>>>>> correct time by some 4 minutes. (It regularly seems to drift by
    >>>>>> about a minute a week.) I guess I'm a bit anal about making sure
    >>>>>> that my files have the right
    >>>>>> date/timestamps on them. Here's how I fixed the dates on the
    >>>>>> photo files.
    >>>>> Why? What possible difference could a time stamp error of 4
    >>>>> minutes make?
    >>>> Like he said, he's "anal".
    >>>>
    >>>>
    >>>> However that prompted me to check my Canon PowerShot A70. It was 16
    >>>> minutes fast after 4+ years and god knows how many times it's sat
    >>>> with flat batteries (NiMH, now using the LSD variety).
    >>>>
    >>>> I agree, 4 minutes is no big deal unless the pics are going to be
    >>>> used as evidence. Even then the clock could be changed...
    >>>>
    >>>> I *do* rely on the /date/ stamp on mine though for pics of my
    >>>> garden as it develops. (Pics can sit on my camera for a long time,
    >>>> it has a bigger storage card than was envisaged when the camera
    >>>> came out and, even on "superfine", stores over 1K pics.)
    >>>>
    >>> If he is anal I am overly so, it matters to me big time that the
    >>> date/time stamp on my photos is correct since I set it to the time
    >>> of the GPS logger I carry and have software that tags the Exif in
    >>> the photos with the Lat/Long of where I took it.

    >>
    >> That's pretty cool!
    >>
    >> However Lawrence offered no such reason for wanting his time to be
    >> shown correctly other than saying "I guess I'm a bit anal". I was
    >> only quoting his own words.
    >>
    >> Cheers,

    > I use a program called renamer from www.den4b.com which will also work
    > with date and time etc in exif tags (among many other tags) one of the
    > uses I have for this is to modify the file date stamp to match the
    > exif date stamp. When I photograph our triathalons I set the camera
    > clock to 00:00:00 at start time this stamps the photo at the time in
    > the race that I took it which makes identifying the competitor in
    > course photos easier and by setting the file date stamp at the same
    > it makes sorting the finishers photos a piece of ease.
    >
    > see http://picasaweb.google.com/rotovegas.half for an example


    Nicely done. :)
    --
    Shaun.

    DISCLAIMER: If you find a posting or message from me
    offensive, inappropriate, or disruptive, please ignore it.
    If you don't know how to ignore a posting, complain to
    me and I will be only too happy to demonstrate... ;-)
    ~misfit~, Oct 28, 2008
    #8
  9. In message <49069f18$>, Collector€NZ wrote:

    > When I photograph our triathalons I set the camera clock to
    > 00:00:00 at start time this stamps the photo at the time in the race
    > that I took it which makes identifying the competitor in course photos
    > easier ...


    The way we did this for a client of mine was the photographer took a picture
    of a reference clock on inserting an empty card. Later they ran an upload
    script which asked what the clock was showing on the first photo, and did
    all the necessary time adjustments for the rest of the contents of the
    card.
    Lawrence D'Oliveiro, Oct 28, 2008
    #9
  10. In message <49069d8c$>, Collector€NZ wrote:

    > ChrisOD wrote:
    >
    >> But that doesn't fix the exif timestamp in the jpeg

    >
    > Nope it dosent but renamer at www.den4b.com does, a very powerful program


    But can that adjust the timestamps of a bunch of files by a given offset?
    Lawrence D'Oliveiro, Oct 28, 2008
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nicearoni

    Thunderbird 1969 email dates?

    nicearoni, Jul 29, 2005, in forum: Firefox
    Replies:
    2
    Views:
    961
    Ralph Fox
    Jul 29, 2005
  2. John
    Replies:
    3
    Views:
    502
    Jaime
    Oct 17, 2003
  3. E Jones

    File Dates on Kodak Pictures

    E Jones, Sep 25, 2003, in forum: Digital Photography
    Replies:
    3
    Views:
    611
    R.S. [Bob] Heuman
    Sep 26, 2003
  4. =?Utf-8?B?ZGF2aWQgc291c3Nhbg==?=

    Complience problem: file dates

    =?Utf-8?B?ZGF2aWQgc291c3Nhbg==?=, Apr 20, 2007, in forum: Windows 64bit
    Replies:
    5
    Views:
    418
    Tony Sperling
    Apr 22, 2007
  5. Lawrence D'Oliveiro

    Mac file dates & AppleShare

    Lawrence D'Oliveiro, Feb 10, 2008, in forum: NZ Computing
    Replies:
    20
    Views:
    1,024
    Nicolaas Hawkins
    Feb 12, 2008
Loading...

Share This Page