newbie 'Find File' question.

Volucris volucris at hotmail.com
Wed Jul 25 16:07:41 EDT 2001


Yeah that was one of the first scripts I ever wrote. It's under 20 lines, so
it's not documented. Just remember os.path.walk() if you friend. It will
only scan the C: drive, but that would be easy to change. I think you need
some platform API stuff (at least on Windows you do) to get the available
drives. I can't remember what it is, though. Does anyone else? Hope this
helps.

---Begin mpsscan.py---

#mp3scan.py
print 'MP3 Scan 0.1 (volucris at hotmail.com)\n\n'
print 'This program will scan the C: drive for files ending in \'mp3\'.'
print 'The results will be stored in \'C:\\mp3scan_results.txt\'.\n'
res = raw_input('Press ENTER to begin.')
if res != 'q':
    import os
    def test(of, dir, files):
        for file in files:
            if file[-3:] == 'mp3':
                of.write(os.path.join(dir, file) + '\n')
    f = open('c:\\mp3scan_results.txt', 'w')
    os.path.walk('c:\\', test, f)
    f.close()
    print '\nScan complete. Check \'C:\\mp3scan_results.txt\' for
results.\n'

res = raw_input('Press ENTER to quit.')

---End mp3scan.py---

--

Volucris (a) hotmail.com
"Eu não falo uma única palavra do português."

"G. Willoughby" <thecalm at NOSPAM.btinternet.com> wrote in message
news:9jn5kb$k16$1 at neptunium.btinternet.com...
> Has anybody coded a script to simulate the windows/mac find file
utilitity?
> i'm using this to help me learn Tkinter and Python. I have created the GUI
i
> just need a few design tips for the search code. basically i need to
search
> all drives (not A:) for a file. any ideas?   :) .
>
> G. WIlloughby.
>
>





More information about the Python-list mailing list