search entire drive say c:
prakash jp
prakash.stack at gmail.com
Fri Feb 12 09:33:18 EST 2010
Thank u Tim Case,
all,
Also how to run the standalone generated from script taking unc path names
to account
regards
Prakash
On Fri, Feb 12, 2010 at 6:31 PM, Tim Chase <python.list at tim.thechases.com>wrote:
> can any of u help to search a file say "abc.txt" in entire c drive
>> (windows)
>> and print the path/s stating such a files presence.
>>
>
> Well, you can just do it from DOS:
>
> c:\> dir /s/b/a abc.txt
>
> Just use os.walk() and check the list of files returned at each
> directory-level iteration.
>
> ROOT = "c:\\"
> fname = "abc.txt".lower()
> for p, d, f in os.walk(ROOT):
> for fn in f:
> if fn.lower() == fname:
> print os.path.join(p, f)
> # break
>
> You might also investigate using os.path.normcase() instead of .lower()
>
> -tkc
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100212/721eeae3/attachment-0001.html>
More information about the Python-list
mailing list