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/.
13 from filecmp
import dircmp
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
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])
37 if not os
.path
.isdir(dir1
) or not os
.path
.isdir(dir2
):
38 print("Arguments must be directories!")
41 dcmp
= dircmp(dir1
, dir2
)
42 print_diff_files(dcmp
)