943,865 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 2596
  • Python RSS
Apr 21st, 2006
0

Searching for Files through a Directory -- PLEASE HELP!!!

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pare80 is offline Offline
2 posts
since Apr 2006
Apr 21st, 2006
0

Re: Searching for Files through a Directory -- PLEASE HELP!!!

Quote 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
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
Reputation Points: 75
Solved Threads: 44
Junior Poster
ghostdog74 is offline Offline
156 posts
since Apr 2006
Apr 21st, 2006
0

Re: Searching for Files through a Directory -- PLEASE HELP!!!

Quote 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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pare80 is offline Offline
2 posts
since Apr 2006
Apr 21st, 2006
0

Re: Searching for Files through a Directory -- PLEASE HELP!!!

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...' )
Last edited by sharma_vivek82; Apr 21st, 2006 at 1:33 am. Reason: why indentation is not working
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sharma_vivek82 is offline Offline
18 posts
since Mar 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: simple code to find a word in any page
Next Thread in Python Forum Timeline: Python speed !





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC