file system iteration

Tim Golden tim.golden at viacom-outdoor.co.uk
Mon Oct 9 10:00:10 EDT 2006


[Georg Brandl]

| rick wrote:
| > In Windows, the file system is disjointed and there is now 
| real 'root' 
| > At least none that I can see. It looks more like this:
| > 
| > | | | | | | |
| > |_|_|_|_|_|_|
| > A B C D E F G
| > 
| > How do you guys handle this when working with scripts that 
| need to touch 
| > all files and folders on a Windows machine? I've been 
| looping through 
| > A-Z like this:

| Which application needs to walk over ALL files? Normally, you 
| just have a starting path and walk over everything under it.

FWIW, I'm inclined to agree with George: whatever system you're
on, blindly walking across all file paths may be more or less of
a good idea. Certain of those drive letters may be removable
drives [*] or network (even web-based) drives with vast acreages
of storage. 

[*] Try doing the following, for example, and watch for the popup:

<code>
import os
for x in os.walk ("a:/"):
  print x

</code>

Depending on how far your "core Python-only" requirement
goes, you should be able to use pywin32 or ctypes to dig into the
Win32 API to pick up volume-level information, altho' I seem to
recall it's mildly messy. Certainly WMI can do things here, but
I suspect you'd want a tighter starting requirement than we're
currently seeing.

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list