How to compare to directories?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • could.net@gmail.com

    #1

    How to compare to directories?

    I want to compare 2 directories: dir1 and dir2.
    What I want to do is to get these informations:
    1. does they have the same number of files and sub-directories?
    2. does each file with the same name have the same size and date
    information?

    So, how can I do it in python?
    Thank you!

  • Marc 'BlackJack' Rintsch

    #2
    Re: How to compare to directories?

    In <1158127776.413 699.170750@e63g 2000cwd.googleg roups.com>, could.net
    wrote:
    I want to compare 2 directories: dir1 and dir2.
    What I want to do is to get these informations:
    1. does they have the same number of files and sub-directories?
    2. does each file with the same name have the same size and date
    information?
    I think `os.listdir()` and the functions in `os.path` will be the tools
    you need.

    Ciao,
    Marc 'BlackJack' Rintsch

    Comment

    • Rob Wolfe

      #3
      Re: How to compare to directories?


      could.net@gmail .com wrote:
      I want to compare 2 directories: dir1 and dir2.
      What I want to do is to get these informations:
      1. does they have the same number of files and sub-directories?
      2. does each file with the same name have the same size and date
      information?
      >
      So, how can I do it in python?
      Here is a nice example:



      Look for description of function walk.

      HTH,
      Rob

      Comment

      • Gabriel Genellina

        #4
        Re: How to compare to directories?

        At Wednesday 13/9/2006 03:09, could.net@gmail .com wrote:
        >I want to compare 2 directories: dir1 and dir2.
        >What I want to do is to get these informations:
        >1. does they have the same number of files and sub-directories?
        >2. does each file with the same name have the same size and date
        >information?
        Look at filecmp.dircmp in the standard library


        Gabriel Genellina
        Softlab SRL





        _______________ _______________ _______________ _____
        Preguntá. Respondé. Descubrí.
        Todo lo que querías saber, y lo que ni imaginabas,
        está en Yahoo! Respuestas (Beta).
        ¡Probalo ya!


        Comment

        Working...