![]() |
|
find_file.py - Printable Version +- HN-Community (https://hacker-newbie.org) +-- Forum: Miscellaneous (https://hacker-newbie.org/forum-86.html) +--- Forum: Coding/Programing (https://hacker-newbie.org/forum-19.html) +---- Forum: Python (https://hacker-newbie.org/forum-81.html) +---- Thread: find_file.py (/thread-2164.html) Pages:
1
2
|
find_file.py - jurank_dankkal - 02-21-2010 PHP Code: #!/usr/bin/env python
import sys
import os
def find_file(tree, pattern, func):
try:
listdir=os.list(tree)
except:
func(tree, '(error)')
return
#
for i in listdir:
path=os.path.join(tree, i)
#
if os.path.isdir(path)
find_file(path, pattern, func) #recursion
#
if pattern in i:
func(path)
def file_found_simple(file_name, message=''):
print '%s%s' %(message, file name)
if _name_=='_main_':
try:
tree=sys.argv[1]
pattern=sys.argv[2]
except:
print '%s<tree><pattern>' %(sys.argv[0])
sys.exit(1)
#
try:
test=os.listdir(tree)
except Exception, e:
print e
sys.exit(2)
#
find_file(tree, pattern, file_found_simple)
bwt linux kk.
RE: find_file.py - Up_ - 02-21-2010 wah...!! sayang..!! aku cman pake WN,,, xixixix RE: find_file.py - jurank_dankkal - 02-22-2010 (02-21-2010, 05:06 PM)Up_Crew Wrote: wah...!! sama kk,sy cm nebeng d'compy tmn...
RE: find_file.py - ./rafaelHN - 02-22-2010 wew. for linux yah.. kalu untuk wn ada gakk :"> RE: find_file.py - jurank_dankkal - 02-26-2010 @atas krang tw sy kk... sundul... RE: find_file.py - boyman - 02-26-2010 windows pakek python bisa ? RE: find_file.py - Up_ - 02-26-2010 hhihihi...!! gk jalan Python sama Pc ku..!! dak tau knpa..!! Aseeemm RE: find_file.py - N4ck0 - 02-26-2010 itu program find di linux kan? tapi di buat di python sama z kayak perint.ah #find / -name "HN.*" xixiix menurut ane gtu om RE: find_file.py - jurank_dankkal - 02-26-2010 (02-26-2010, 03:32 PM)N4ck0 Wrote: itu program find di linux kan? ya kk n4ck0 bwt find di linux dijadiin python kk.. ![]() versi laen : #find / -name "HN.*"
RE: find_file.py - y3d0wn - 02-26-2010 thanks brader jurank_dangkkal tak oprek dulu di linux ku ok |