Recursive Search in python
12 November 2009 at 4:19 PM | Posted in Python | Leave a commentTags: Python
I do this script to make recursive searches in a specified folder in Ubuntu Server.I shere it and hope will be usefull to someone:#! /usr/bin/env python import os def search(path,file_name): try: files = os.listdir(path) trunk = 0 except OSError: print “Access Denied: ” + path trunk = 1 if trunk == 0: for f in files: if os.path.isdir(path + f): search(path + f + ‘/’,file_name) else: if file_name == f: print ‘Found : ‘ + path + f if __name__ == ‘__main__’: path = raw_input(”Search Folder: “) file = raw_input(”File to Search: “) search(path,file)
Leave a Comment »
RSS feed for comments on this post. TrackBack URI
Leave a Reply
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.

