Last active
January 8, 2019 08:14
-
-
Save vernomcrp/68629c4a118cf7a27d662b8e8fd9e9e2 to your computer and use it in GitHub Desktop.
Simple find duplicate file in any other directory
This file contains hidden or 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 | |
| import os | |
| # simple and dirty, no any beautiful patt but just work hhh | |
| class CheckNode: | |
| def __init__(self, base_dir, debug): | |
| self.base_dir = os.listdir(base_dir) | |
| self.debug = debug | |
| def compare_to(self, comparable_dir): | |
| duplicate_list = [] | |
| comparable_list = os.listdir(comparable_dir) | |
| for candidate in self.base_dir: | |
| for comparable in comparable_list: | |
| if candidate.lower() in comparable.lower(): | |
| if self.debug: | |
| print(f"-> found {candidate} <-> {comparable} in {comparable_dir}") | |
| duplicate_list.append(candidate) | |
| for index, candidate in enumerate(duplicate_list): | |
| print(f"{index}:{candidate} found in {comparable_dir}") | |
| @staticmethod | |
| def parse(path, debug=False): | |
| return CheckNode(path, debug) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment