473,385 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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!

Sep 13 '06 #1
3 1885
In <11**********************@e63g2000cwd.googlegroups .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
Sep 13 '06 #2

co*******@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:

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

Look for description of function walk.

HTH,
Rob

Sep 13 '06 #3
At Wednesday 13/9/2006 03:09, co*******@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!
http://www.yahoo.com.ar/respuestas

Sep 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Robin Siebler | last post by:
I have two directory trees that I want to compare and I'm trying to figure out what the best way of doing this would be. I am using walk to get a list of all of the files in each directory. I...
4
by: could ildg | last post by:
I want to compare 2 directories, and find If all of theire sub-folders and files and sub-files are identical.. If not the same, I want know which files or folders are not the same. I know filecmp...
0
by: Jeff Higgins | last post by:
Hi all Newbie to XPath. Can someone help with an XPath expression(s) that will accomplish the following using JAXP in J2SE-1.5. Thanks Jeff Higgins In a class I have two private org.w3c.dom...
1
by: Heath | last post by:
I'm dealing with a C# application that monitors changes to the file system, and need to exclude irrelevent directories, temp directories for example. Is there any way to identify such...
8
by: Peter Larsen [] | last post by:
Hi, If i have a mapped drive and an UNC path - both pointing to the same directory on the server, how do i determine if they match (point to the same directory on the server) ?? Thank you....
4
by: rn5a | last post by:
I have a ListBox which should list all the files & directories that exist in a particular directory. The problem is I can get the ListBox to list either all the files or all the directories but not...
5
by: stamatis32 | last post by:
Hello everybody, i want to make a prog to compare the contents of 2 dirs. You can compare easily 2 files, but how this happend with dirs. I am very confused, i dont know where to start from, can...
1
by: Richard | last post by:
I'm writing code to compare two directories side-by-side, like FolderMatch or FolderSync. I've used ListBoxes in VB6, so have the idea about concatenating strings for list items, but have no...
6
by: =?Utf-8?B?WW9naSBXYXRjaGVy?= | last post by:
Hello, I am using Visual Studio-2003. I created a project to build my library. Since I am using third party libraries as well, I have specified those additional library dependencies in project...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.