View Single Post
Old Jul 23rd, 2005, 1:27 PM   #1
SaturN
Programmer
 
Join Date: Apr 2005
Location: Uk
Posts: 68
Rep Power: 4 SaturN is on a distinguished road
Cool An alternative to 'Windows Search'...

got sick of windows search funtion, seemed slow to me!! might just be crap computer, so i decided to cook up my own version in Python, so if anyone is interested in a replacement!
Here it is

#Python version 4.1
import re, os, sys
print '''
This Program Is A File Search Program
enter a path
then enter a search term
program will return any files found!
'''
def Main():
	path = raw_input("Path: ")
	s = raw_input("Search: ")
	s = s.lower()
	s = s.split()
	for root, dirs, files in os.walk(path):
		for name in files:
			for a in range(len(s)):
				if re.search('.*?%s'% (s[a]), name.lower()):
					print '\nFile Found'
					print os.path.join(root, name)
		for name in dirs:
			for a in range(len(s)):
				if re.search('.*?%s'% (s[a]), name.lower()):
					print '\nDirectory'
					print os.path.join(root, name)
	s_a = raw_input("New Search? (Y/N) ")
	if s_a.lower() == 'n':
		sys.exit()
	else:
		Main()
Main()

If anyone likes the idea, I might move on to a GUI version, and another which will included a startfile function,
Lemme know of any glitches Thanks
__________________
while me is alive:
	make(life,simple)

Last edited by SaturN; Jul 23rd, 2005 at 1:46 PM. Reason: sys not imported :DOH:
SaturN is offline   Reply With Quote