Results 1 to 3 of 3

Thread: script help...how to change timestamp on all files/folders after a certain date

  1. #1
    Join Date
    Jul 2013
    Beans
    171

    script help...how to change timestamp on all files/folders after a certain date

    hi,

    I need help on a script that will change the timestamp on all files and folders & sub-files and
    sub-folders, that are only after a certain date.

    Otherwords, for example, in a folder I may have files and sub-folders with some dates of oct 3, 2009 and some that are
    june 17, 2013. I want to recursely run through this folder and change all of those after ( or equal to & after, don't matter )
    june 17, 2013 to jan 1, 2013.

    I think the script may revolve around this, but I don't know how to look for only timestamps of a certain date or latter
    I think I would need to cd into the folder first:

    Code:
    find .  -exec  touch  -d  '17 Jun 2013 01:01'  {}
    Thanks

  2. #2
    Join Date
    Dec 2009
    Beans
    195

    Re: script help...how to change timestamp on all files/folders after a certain date

    Quote Originally Posted by sam_baker2 View Post
    hi,

    I need help on a script that will change the timestamp on all files and folders & sub-files and
    sub-folders, that are only after a certain date.

    [...]
    You can let 'find' do the date comparisons, then just 'touch' the output. Try it first on a test directory.

    Code:
    find . -newermt "June 17 2013" -exec touch -d 'Jan 1 2013 01:01' {} +
    The other way is creating a template file, then using it as reference when comparing timestamps, with -newer, -anewer options. More info here:

    http://www.gnu.org/software/findutil...ing-Timestamps

  3. #3
    Join Date
    Jul 2013
    Beans
    171

    Re: script help...how to change timestamp on all files/folders after a certain date

    Thanks erind,
    that seemed to work. I will try this more some more tonight.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •