Fix typo
[LibreOffice.git] / bin / find-duplicated-files.py
blob08d90076c3f4e8ff0d3cb33291e2573bf6c07e28
1 #!/usr/bin/env python3
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 import os
11 import sys
13 from filecmp import dircmp
15 """
16 This script compares two directories and lists the files which are the same in both directories.
17 Intended to find duplicate icons among icon themes.
19 Adopted from the example at https://docs.python.org/3.5/library/filecmp.html
21 Usage: ./bin/findduplicatefiles dir1 dir2
22 """
24 def print_diff_files(dcmp):
25 for name in dcmp.same_files:
26 print("%s found in %s and %s" % (name, dcmp.left, dcmp.right))
27 for sub_dcmp in dcmp.subdirs.values():
28 print_diff_files(sub_dcmp)
30 if len(sys.argv) != 3:
31 print("Usage: %s dir1 dir2" % sys.argv[0])
32 exit()
34 dir1 = sys.argv[1]
35 dir2 = sys.argv[2]
37 if not os.path.isdir(dir1) or not os.path.isdir(dir2):
38 print("Arguments must be directories!")
39 exit()
41 dcmp = dircmp(dir1, dir2)
42 print_diff_files(dcmp)