Created
March 26, 2021 04:26
-
-
Save legendmohe/5ec68bd60903a64c049dc4bc7177bc51 to your computer and use it in GitHub Desktop.
在两个目录查找同名文件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
"""find_same_res.py: ...""" | |
__author__ = "hexinyu" | |
import os | |
import argparse | |
import time | |
class DupResFinder(object): | |
def find(self, args): | |
self._find(args.first, args.second) | |
def _find(self, firstDir, secondDir): | |
firstSet = set() | |
for subdir, dirs, files in os.walk(firstDir): | |
for file in files: | |
firstSet.add(os.path.basename(os.path.join(subdir, file))) | |
secondSet = set() | |
for subdir, dirs, files in os.walk(secondDir): | |
for file in files: | |
secondSet.add(os.path.basename(os.path.join(subdir, file))) | |
print("\n".join(firstSet & secondSet)) | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser() | |
parser.add_argument("-f", "--first", default=".") | |
parser.add_argument("-s", "--second", default=".") | |
args = parser.parse_args() | |
print(DupResFinder().find(args)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment