• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Script to update 'created on' timestamp

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Script to update 'created on' timestamp

    Maybe a long shot but thought I'd ask.

    Background: Every year when we go on hols I forget to update the current date/time on the camera, which means that all the image files have a created on of 01 Jan 2010 + the holiday duration.

    I'd like a script/prog/app that I can run in a directory that will update the created on timestamp relative to a specified value. i.e it replaces 01/01/2010 + holiday elapsed time with 16/09/2014 + HET

    Any ideas?

    TIA

    Pondy.

    #2
    Originally posted by Pondlife View Post
    Maybe a long shot but thought I'd ask.

    Background: Every year when we go on hols I forget to update the current date/time on the camera, which means that all the image files have a created on of 01 Jan 2010 + the holiday duration.

    I'd like a script/prog/app that I can run in a directory that will update the created on timestamp relative to a specified value. i.e it replaces 01/01/2010 + holiday elapsed time with 16/09/2014 + HET

    Any ideas?

    TIA

    Pondy.
    What operating system?
    merely at clientco for the entertainment

    Comment


      #3
      Originally posted by eek View Post
      What operating system?
      Don't say windows. NF will have a heart atack.

      Comment


        #4
        Don't know whether this still works, but it looks like it might do the trick - BulkFileChanger: Change date/time/attributes of multiple files
        Best Forum Advisor 2014
        Work in the public sector? You can read my FAQ here
        Click here to get 15% off your first year's IPSE membership

        Comment


          #5
          Originally posted by eek View Post
          What operating system?
          Mac, Win or Ubuntu.

          Originally posted by TheFaQQer View Post
          Don't know whether this still works, but it looks like it might do the trick - BulkFileChanger: Change date/time/attributes of multiple files
          Cheers Faq. Will take look.

          Comment


            #6
            Originally posted by Pondlife View Post
            Maybe a long shot but thought I'd ask.

            Background: Every year when we go on hols I forget to update the current date/time on the camera, which means that all the image files have a created on of 01 Jan 2010 + the holiday duration.

            I'd like a script/prog/app that I can run in a directory that will update the created on timestamp relative to a specified value. i.e it replaces 01/01/2010 + holiday elapsed time with 16/09/2014 + HET

            Any ideas?

            TIA

            Pondy.
            If a Unix system (or Unix-like) 'touch -t timestamp_you_want filename(s) - wildcards/regex works in the filename bit.

            eg: touch -t 201409161030 pic*.jpg

            for a timestamp of 16th of Sept 2014 at 10:30am......

            EDIT: reread - this won't do exactly what you want, you'd need to do some awk/sed/grep'ing on a listing to squirt into a for loop.
            Last edited by stek; 16 September 2014, 10:56.

            Comment


              #7
              Originally posted by stek View Post
              If a Unix system (or Unix-like) 'touch -t timestamp_you_want filename(s) - wildcards/regex works in the filename bit.

              eg: touch -t 201409161030 pic*.jpg

              for a timestamp of 16th of Sept 2014 at 10:30am......

              EDIT: reread - this won't do exactly what you want, you'd need to do some awk/sed/grep'ing on a listing to squirt into a for loop.

              Cheers Stek.

              Comment


                #8
                In case anyone else is ever looking for something similar, I've pinched this off askubuntu and it works fine on my MBP. Just add in the number of days you want to shift the timestamp by (73days in the case below).

                Note: this only updates the 'modified on' if it's later than 'created on' but I'll fiddle when I get the chance.

                Ta all.



                #!/bin/bash

                # find specific files
                files=$(find . -type f -name '*.jpg')

                # use newline as file separator (handle spaces in filenames)
                IFS=$'\n'

                for f in ${files}
                do
                # read file modification date using stat as seconds
                # adjust date using date and print in correct format
                # change file time using touch
                touch -t $(date -v +73d -r $(stat -f %m "${f}") +%Y%m%d%H%M.%S) "${f}"
                done

                Comment


                  #9
                  Originally posted by Pondlife View Post
                  In case anyone else is ever looking for something similar, I've pinched this off askubuntu and it works fine on my MBP. Just add in the number of days you want to shift the timestamp by (73days in the case below).
                  I found that, but couldn't get it to work on my Linux box (which is very out of date now), so didn't post it.

                  The next step for you to consider is to go through the renamed files and take the new modified date and use that to correct the EXIF data in the image file
                  Best Forum Advisor 2014
                  Work in the public sector? You can read my FAQ here
                  Click here to get 15% off your first year's IPSE membership

                  Comment


                    #10
                    Originally posted by TheFaQQer View Post
                    I found that, but couldn't get it to work on my Linux box (which is very out of date now), so didn't post it.

                    The next step for you to consider is to go through the renamed files and take the new modified date and use that to correct the EXIF data in the image file

                    http://www.sentex.net/~mwandel/jhead/usage.html

                    Will have a look at the weekend hopefully

                    Comment

                    Working...
                    X