Try dumping all the files under the specified directory with breadth-first search (BFS).
bfs.py
#!/usr/bin/env python
#-*- encoding:utf-8 *-*
import sys
import os
import glob
if len(sys.argv) != 2:
print os.path.basename(sys.argv[0]) + ' <directory>'
exit(None)
target_root = sys.argv[1]
que = []
que.append(target_root)
while len(que) > 0:
target_dir = que.pop(0)
for node in glob.glob(os.path.join(target_dir, '*')):
if os.path.isdir(node):
que.append(node)
else:
print(node)
exit(None)
Recommended Posts