import os
"""判断两个文件夹里是否有相同文件名的文件"""
def fileList(path):
filelist = {}
n = 1
for root,folders,files in os.walk(path):
for file in files:
print('\rHas scanned %s files ------- %s' % (n,path) ,end='')
n += 1
filelist[file] = os.path.join(root,file)
print('\n')
return filelist
def compare(path1, path2):
dict1 = fileList(path1)
dict2 = fileList(path2)
print('---------------------------------Same Files--------------------------------')
for key in dict1:
if key in dict2:
print(dict1[key], dict2[key], sep=' <-------> ')
if __name__ == '__main__':
path1 = input('Path1:')
path2 = input('Path2:')
compare(path1,path2)
print("Done.")