File date attribute

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bruce R Graham

    #1

    File date attribute

    Hi: am a Newbie and this is my first script:
    We were recently burgled and had our computers stolen. Easy to replace,
    but the data that was lost is years and years of work. I've
    investigated offsite data backup but it seems expensive. In any case,
    the data we have is not volumous.
    Rather, would like to send emails of files to a backup address at
    gmail.
    So, this is my plan:
    Run a script in cron.daily. The script should check a timestamp placed
    by the last occurrence of that script. Then check my home folder for
    files modified between that timestamp and now. Then send those files
    off to gmail.
    I have most of the pieces in place, except I can't find out how to
    retrieve the date modified attribute of a file. Does anybody know how
    to do that?
    I'll post the full script when I'm done in case there is anybody who
    would like to use it.
    Kindest,
    BG

  • Sybren Stuvel

    #2
    Re: File date attribute

    Bruce R Graham enlightened us with:[color=blue]
    > Run a script in cron.daily. The script should check a timestamp
    > placed by the last occurrence of that script. Then check my home
    > folder for files modified between that timestamp and now. Then send
    > those files off to gmail.
    > I have most of the pieces in place, except I can't find out how to
    > retrieve the date modified attribute of a file. Does anybody know
    > how to do that?[/color]

    man find. You can even tell it to list all files older than a
    reference file.

    Sybren
    --
    The problem with the world is stupidity. Not saying there should be a
    capital punishment for stupidity, but why don't we just take the
    safety labels off of everything and let the problem solve itself?
    Frank Zappa

    Comment

    • Fredrik Lundh

      #3
      Re: File date attribute

      Bruce R Graham wrote:
      [color=blue]
      > I have most of the pieces in place, except I can't find out how to
      > retrieve the date modified attribute of a file. Does anybody know how
      > to do that?[/color]

      t = os.path.getmtim e(filename)

      returns the timestamp as seconds since the epoch. see the "time" and
      "datetime" modules for ways to convert this to other formats (if needed).

      </F>



      Comment

      Working...