| | |
Searching for Files through a Directory -- PLEASE HELP!!!
![]() |
•
•
Join Date: Apr 2006
Posts: 148
Reputation:
Solved Threads: 40
•
•
•
•
Originally Posted by pare80
Hello to all,
I am trying to create a script that will go through certain directorys in Windows and pull out the files I stated by extentions. Which will then later copy to a location either on the local machine or an external HD.
Any assistence will be greatly appricated.
Thanx in advance,
ParE
anyway, you can look up the manuals of some of these tools
- os.walk
- glob
- shutil
- os.path.splitext
to achieve what you need
•
•
Join Date: Apr 2006
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by ghostdog74
what have you tried so far?
anyway, you can look up the manuals of some of these tools
- os.walk
- glob
- shutil
- os.path.splitext
to achieve what you need
I have tried the above
For example
The path and file's could be simliar
Ex: C:\Lotus\Notes\Data\mail*\*
mail could be any number from mail 1 - 100 and whatever files that follow.
Ex: C:\Lotus\Notes\Data\mail10\myname.nsf
I just need to be able to back up myname.nsf -- Please help - would like to get this project done in Python.
ParE
•
•
Join Date: Mar 2006
Posts: 18
Reputation:
Solved Threads: 0
i think this will help you out, this is not the exact solution of your problem, but now you can find yourself.please indent it yourself, i am unable to indent in message box.
code:
import os
def directoryWalker( unused, dirName, nameList ):
print "Entering new directory: " + dirName
filename = raw_input("Enter file name : ")
if filename in nameList:
print "file is present"
print " " + os.path.join( dirName, filename )
print " "
else:
print "file is not here"
if __name__ == '__main__':
os.path.walk( os.curdir, directoryWalker, None )
raw_input( '\n\nPress Enter to exit...' )
code:
import os
def directoryWalker( unused, dirName, nameList ):
print "Entering new directory: " + dirName
filename = raw_input("Enter file name : ")
if filename in nameList:
print "file is present"
print " " + os.path.join( dirName, filename )
print " "
else:
print "file is not here"
if __name__ == '__main__':
os.path.walk( os.curdir, directoryWalker, None )
raw_input( '\n\nPress Enter to exit...' )
Last edited by sharma_vivek82; Apr 21st, 2006 at 1:33 am. Reason: why indentation is not working
Best wishes,
Vivek Sharma
Zope/Python Developer
Vivek Sharma
Zope/Python Developer
![]() |
Similar Threads
- parsing multiple files in current directory (Perl)
- Reading files in a directory (C)
- Create EXE to delete files in TEMP Directory (Windows NT / 2000 / XP)
- A question about deleting Temp files (Windows NT / 2000 / XP)
- ASP.Net Directory Problems (ASP.NET)
- playing mp3 files on the click of a button (Visual Basic 4 / 5 / 6)
- hijacked! (Viruses, Spyware and other Nasties)
- Does Samba send deleted files to a recycle bin? (*nix Software)
Other Threads in the Python Forum
- Previous Thread: simple code to find a word in any page
- Next Thread: Python speed !
| Thread Tools | Search this Thread |
address anydbm app bash beginner bits changecolor cipher clear conversion coordinates corners cturtle curves definedlines development dictionary dynamic events examples excel external feet file float format function generator getvalue gui handling homework iframe images import input ip java keycontrol line linux list lists loan loop maintain matching maze millimeter mouse number numbers output parsing path port prime programming projects py2exe pygame pymailer python queue random rational raw_input recursion recursive scrolledtext searchingfile singleton slicenotation split string strings tails terminal text threading time tlapse tooltip tuple tutorial type ubuntu unicode url urllib urllib2 valueerror variable variables vigenere web whileloop word wxpython xlwt





