473,473 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

comparing files

56 New Member
how can I compare two files(their size and date modified)?Is it posible?
Jan 15 '08 #1
6 3976
bvdet
2,851 Recognized Expert Moderator Specialist
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.
Expand|Select|Wrap|Line Numbers
  1. fn = 'file_name'
  2. >>> os.path.getsize(fn)
  3. 10424L
  4. >>> os.path.getmtime(fn)
  5. 1200398316
  6. >>> 
Jan 15 '08 #2
heiro
56 New Member
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.
Expand|Select|Wrap|Line Numbers
  1. fn = 'file_name'
  2. >>> os.path.getsize(fn)
  3. 10424L
  4. >>> os.path.getmtime(fn)
  5. 1200398316
  6. >>> 

thanks for that. But when i get the size of folder it will return 0byte.How can solve this?
Jan 17 '08 #3
bvdet
2,851 Recognized Expert Moderator Specialist
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.
Jan 17 '08 #4
heiro
56 New Member
Sum the sizes of all the files in the directory.

yap thats what i do... no other way to do this??
Jan 18 '08 #5
bvdet
2,851 Recognized Expert Moderator Specialist
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.
Jan 18 '08 #6
diegososa
19 New Member
You could capture the output of the system-dependent command to get the directory size... i don't know which one is more efficient.
Jan 26 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Dan Stromberg | last post by:
We will soon have 3 copies, for testing purposes, of what should be about 4.5 terrabytes of data. Rather than cmp'ing twice, to verify data integrity, I was thinking we could speed up the...
8
by: Corno | last post by:
Hi all, Does anybody know a command line tool (linux or windows) that can compare 2 XML files. There's only 1 extra requirement that makes it a bit more complicated: the order of attributes or...
18
by: HerrLucifer | last post by:
I am each day becoming more and more addicted to the new .Net framework because of its cool RAD facilities. However, performance and speed is extremely important for my application development. I...
4
by: ddd | last post by:
I am trying to build a diff tool that allows me to compare two HTML files. I am looking for resources on how to achive this. The main problem is that I do not want to simply highlight the line of...
5
by: Peteroid | last post by:
I realize this might not be the correct newsgroup, but since I have a general question I need answering in the context of doing a managed VC++.NET Managed application, this is as good a place as...
0
by: richardkreidl | last post by:
I have the following hash script that I use to compare two text files. 'Class Public Class FileComparison Public Class FileComparisonException Public Enum ExceptionType U 'Unknown A 'Add...
3
by: s99999999s2003 | last post by:
hi i wrote some code to compare 2 files. One is the base file, the other file i got from somewhere. I need to compare this file against the base, eg base file abc def ghi eg another file
3
by: system55 | last post by:
are there any commands that can compare two files? Comparing in the sense that the two files are alike... Because I wrote a program that makes a backup file of another file... Just want to know if...
0
by: Gabriel Genellina | last post by:
En Thu, 15 May 2008 06:02:29 -0300, Beema shafreen <beema.shafreen@gmail.comescribió: *three* columns? You menction only two of them. Do you have to syncrhonize both listings? That is,...
1
by: Avi1 | last post by:
Hi, I got the code (from the internet)for comparing two files and showing the difference in contents.Now,I tried the same code for two files written in japanese language(kanji).If I save the two...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.