import glob
print 'Named explicitly:'
for name in glob.glob('dir/subdir/*'):
print ' ', name
print 'Named with wildcard:'
for name in glob.glob('dir/*/*'):
print ' ', name
# Python program to find files
# recursively using Python
import glob
# Returns a list of names in list files.
print("Using glob.glob()")
files = glob.glob('/home/geeks/Desktop/gfg/**/*.txt',
recursive = True)
for file in files:
print(file)
# It returns an iterator which will
# be printed simultaneously.
print("
Using glob.iglob()")
for filename in glob.iglob('/home/geeks/Desktop/gfg/**/*.txt',
recursive = True):
print(filename)
glob.glob("/home/ismail/*.txt")