import os, re, shutil, sys, time
start = time.time()
lst_file = 'list2.txt'
#lst_file = sys.argv[1]
search_dir = "./dir"
#search_dir = sys.argv[2]
tag_dir = os.path.expandvars('$HOME') + "/Desktop/tmp/"
def search_file(dir_name):
num_files = 0
for dirPath, dirNames, fileNames in os.walk(dir_name):
for f in fileNames:
num_files += 1
basename = os.path.splitext(f)[0]
if line == basename:
print "finded >>", os.path.join(dirPath, f)
old = os.path.join(dirPath, f)
new = tag_dir + f
shutil.copy(old, new)
return num_files
if not os.path.isdir(tag_dir):
os.mkdir(tag_dir)
num_files = 0
with open(lst_file) as f:
for line in f.readlines():
line = line[:-1]
num_files = search_file(search_dir)
#print "-----print dict list-----"
#print(dict.items())
#print
print "Total search files:", num_files
end = time.time()
print "Elapsed time:", end - start
aW1wb3J0IG9zLCByZSwgc2h1dGlsLCBzeXMsIHRpbWUKCnN0YXJ0ID0gdGltZS50aW1lKCkKbHN0X2ZpbGUgPSAnbGlzdDIudHh0JwojbHN0X2ZpbGUgPSBzeXMuYXJndlsxXQpzZWFyY2hfZGlyID0gIi4vZGlyIgojc2VhcmNoX2RpciA9IHN5cy5hcmd2WzJdCnRhZ19kaXIgPSBvcy5wYXRoLmV4cGFuZHZhcnMoJyRIT01FJykgKyAiL0Rlc2t0b3AvdG1wLyIKCmRlZiBzZWFyY2hfZmlsZShkaXJfbmFtZSk6CiAgICBudW1fZmlsZXMgPSAwCiAgICBmb3IgZGlyUGF0aCwgZGlyTmFtZXMsIGZpbGVOYW1lcyBpbiBvcy53YWxrKGRpcl9uYW1lKToKICAgICAgICAgICAgZm9yIGYgaW4gZmlsZU5hbWVzOgogICAgICAgICAgICAgICAgbnVtX2ZpbGVzICs9IDEKICAgICAgICAgICAgICAgIGJhc2VuYW1lID0gb3MucGF0aC5zcGxpdGV4dChmKVswXQogICAgICAgICAgICAgICAgaWYgbGluZSA9PSBiYXNlbmFtZToKICAgICAgICAgICAgICAgICAgICBwcmludCAiZmluZGVkID4+Iiwgb3MucGF0aC5qb2luKGRpclBhdGgsIGYpCiAgICAgICAgICAgICAgICAgICAgb2xkID0gb3MucGF0aC5qb2luKGRpclBhdGgsIGYpCiAgICAgICAgICAgICAgICAgICAgbmV3ID0gdGFnX2RpciArIGYKICAgICAgICAgICAgICAgICAgICBzaHV0aWwuY29weShvbGQsIG5ldykKICAgIHJldHVybiBudW1fZmlsZXMKCmlmIG5vdCBvcy5wYXRoLmlzZGlyKHRhZ19kaXIpOgogICAgb3MubWtkaXIodGFnX2RpcikKCm51bV9maWxlcyA9IDAKd2l0aCBvcGVuKGxzdF9maWxlKSBhcyBmOgogICAgZm9yIGxpbmUgaW4gZi5yZWFkbGluZXMoKToKICAgICAgICBsaW5lID0gbGluZVs6LTFdCiAgICAgICAgbnVtX2ZpbGVzID0gc2VhcmNoX2ZpbGUoc2VhcmNoX2RpcikKI3ByaW50ICItLS0tLXByaW50IGRpY3QgbGlzdC0tLS0tIgojcHJpbnQoZGljdC5pdGVtcygpKQojcHJpbnQKcHJpbnQgIlRvdGFsIHNlYXJjaCBmaWxlczoiLCBudW1fZmlsZXMKZW5kID0gdGltZS50aW1lKCkKcHJpbnQgIkVsYXBzZWQgdGltZToiLCBlbmQgLSBzdGFydA==