473,407 Members | 2,598 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,407 software developers and data experts.

Scanning through Directory

There is a portable way of reading directories
os.listdir
in conjunction with
os.stat and a little help from os.path.split and os.path.join
Though using os.stat gives programs a somewhat clumbsy look,
I had not been too annoyed with it until I tried to scan a whole disk.
Reworking the join and split operations already gave a considerable
speed-up

As I need it for Windows I then with very little effort changed to:
win32api.FindFiles
(I already had used win32api.GetDiskFreeSpace)

This was a breakthrough: 5 secs instead of 50+ !

os.listdir seems to do little more than win32api FindFiles
How can it be so slow???
Why is there no portable way of getting "DiskFreeSpace" info
Questions and Questions....

I strongly recommend the win32api calls it you have similar applications.
The interface is extremely simple and the only penalty is non-compatibility
;-)

I also recommend to use the Python profiler from time to time for programms
running more than one second. It might give you interesting insights...

Kindly
Michael Peuser


Jul 18 '05 #1
1 2830
Did you try os.path.walk() in your experiments?
If you did, you could post the profile data for it too.
I find it one of the most useful functions defined in
the os.path module.

Thanks!

Anand

"Michael Peuser" <mp*****@web.de> wrote in message news:<bh*************@news.t-online.com>...
There is a portable way of reading directories
os.listdir
in conjunction with
os.stat and a little help from os.path.split and os.path.join
Though using os.stat gives programs a somewhat clumbsy look,
I had not been too annoyed with it until I tried to scan a whole disk.
Reworking the join and split operations already gave a considerable
speed-up

As I need it for Windows I then with very little effort changed to:
win32api.FindFiles
(I already had used win32api.GetDiskFreeSpace)

This was a breakthrough: 5 secs instead of 50+ !

os.listdir seems to do little more than win32api FindFiles
How can it be so slow???
Why is there no portable way of getting "DiskFreeSpace" info
Questions and Questions....

I strongly recommend the win32api calls it you have similar applications.
The interface is extremely simple and the only penalty is non-compatibility
;-)

I also recommend to use the Python profiler from time to time for programms
running more than one second. It might give you interesting insights...

Kindly
Michael Peuser

Jul 18 '05 #2

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

Similar topics

2
by: Dean | last post by:
Hi I've got a question relating to using Javascript on an Intranet. I have a directory with a list of files in the format week36.xls, week37.xls and I want to write a script that will scan...
4
by: Zen | last post by:
I'm using Access 2000, and I'd like to know if there is a way to use a scanner (flatbed, doc-feed, etc) to scan forms with OMR or OCR software, and have the data be automatically (or if not...
4
by: Nazgob | last post by:
Hello! I'm looking for cross-platform directory scanning library working with ansi C. I need to use in in GNU Linux and Windows. I need to do simple directory and files opertionson both OS, can...
10
by: Alan Searle | last post by:
I would like to scan a directory structure into XML to offer navigation functionality in HTML / XSL pages. My questions are: 1. Which is the best structure to store variable depth heirarchies...
2
by: Alan Searle | last post by:
I would like to 'grab' certain directory trees and then store them in a table. At the moment, I writing my own VBA to do this but I cannot help thinking that there must already be something...
6
by: Bob Alston | last post by:
I am looking for others who have built systems to scan documents, index them and then make them accessible from an Access database. My environment is a nonprofit with about 20-25 case workers who...
4
by: tshad | last post by:
We have a few pages that accept uploads and want to scan the files before accepting them. Does Asp.net have a way of doing a virus scan? We are using Trendmicro to scan files and email but don't...
23
by: Rotsey | last post by:
Hi, I am writing an app that scans hard drives and logs info about every fine on the drive. The first iteration of my code used a class and a generic list to store the data and rhis took...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.