comparing files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • heiro
    New Member
    • Jul 2007
    • 56

    comparing files

    how can I compare two files(their size and date modified)?Is it posible?
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Originally posted by heiro
    how can I compare two files(their size and date modified)?Is it posible?
    You can use the os module to determine the file size in bytes and the time of last modification as the number of second since the epoch.[code=Python]fn = 'file_name'
    >>> os.path.getsize (fn)
    10424L
    >>> os.path.getmtim e(fn)
    1200398316
    >>> [/code]

    Comment

    • heiro
      New Member
      • Jul 2007
      • 56

      #3
      Originally posted by bvdet
      You can use the os module to determine the file size in bytes and the time of last modification as the number of second since the epoch.[code=Python]fn = 'file_name'
      >>> os.path.getsize (fn)
      10424L
      >>> os.path.getmtim e(fn)
      1200398316
      >>> [/code]

      thanks for that. But when i get the size of folder it will return 0byte.How can solve this?

      Comment

      • bvdet
        Recognized Expert Specialist
        • Oct 2006
        • 2851

        #4
        Originally posted by heiro
        thanks for that. But when i get the size of folder it will return 0byte.How can solve this?
        Sum the sizes of all the files in the directory.

        Comment

        • heiro
          New Member
          • Jul 2007
          • 56

          #5
          Originally posted by bvdet
          Sum the sizes of all the files in the directory.

          yap thats what i do... no other way to do this??

          Comment

          • bvdet
            Recognized Expert Specialist
            • Oct 2006
            • 2851

            #6
            Originally posted by heiro
            yap thats what i do... no other way to do this??
            Not that I am aware of. If you find a way, please post your solution.

            Comment

            • diegososa
              New Member
              • Oct 2007
              • 19

              #7
              You could capture the output of the system-dependent command to get the directory size... i don't know which one is more efficient.

              Comment

              Working...