How to compare to directories?

C

could.net

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!
 
M

Marc 'BlackJack' Rintsch

could.net said:
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
 
R

Rob Wolfe

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
 
G

Gabriel Genellina

At said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top