How to compare to directories?

Discussion in 'Python' started by could.net@gmail.com, Sep 13, 2006.

  1. Guest

    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!
    , Sep 13, 2006
    #1
    1. Advertising

  2. In <>, 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
    Marc 'BlackJack' Rintsch, Sep 13, 2006
    #2
    1. Advertising

  3. Rob Wolfe Guest

    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:

    http://docs.python.org/lib/os-file-dir.html

    Look for description of function walk.

    HTH,
    Rob
    Rob Wolfe, Sep 13, 2006
    #3
  4. At Wednesday 13/9/2006 03:09, 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!
    http://www.yahoo.com.ar/respuestas
    Gabriel Genellina, Sep 13, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joel Finkel
    Replies:
    0
    Views:
    491
    Joel Finkel
    Sep 12, 2003
  2. Jeffry van de Vuurst
    Replies:
    2
    Views:
    525
    Jeffry van de Vuurst
    Jul 30, 2003
  3. =?Utf-8?B?TGFzc2UgTmlsc3Nvbg==?=

    Multiple bin-directories with virtual directories?

    =?Utf-8?B?TGFzc2UgTmlsc3Nvbg==?=, Nov 9, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    825
    =?Utf-8?B?TGFzc2UgTmlsc3Nvbg==?=
    Nov 9, 2004
  4. Paul F
    Replies:
    4
    Views:
    630
    Mark Fitzpatrick
    Jun 25, 2008
  5. Adam Petrie
    Replies:
    8
    Views:
    306
    Adam Petrie
    Oct 11, 2004
Loading...

Share This Page