FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PySimpleGUI/DemoPrograms/Demo_DuplicateFileFinder.py at 6.1 · PySimpleGUI/PySimpleGUI · GitHub
PySimpleGUI
/
PySimpleGUI
Public
Notifications
You must be signed in to change notification settings
Fork
1.8k
Star
13.8k
Code
Issues
708
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
PySimpleGUI
/
DemoPrograms
/
Demo_DuplicateFileFinder.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
70 lines (59 loc) · 2.41 KB
Breadcrumbs
PySimpleGUI
/
DemoPrograms
/
Demo_DuplicateFileFinder.py
Copy path
File metadata and controls
70 lines (59 loc) · 2.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
import
PySimpleGUI
as
sg
import
hashlib
import
os
'''
Find dups with PySimpleGUI
Copyright 2018-2026 PySimpleGUI. All rights reserved.
'''
# ====____====____==== FUNCTION DeDuplicate_folder(path) ====____====____==== #
# Function to de-duplicate the folder passed in #
# --------------------------------------------------------------------------- #
def
FindDuplicatesFilesInFolder
(
path
):
shatab
=
[]
total
,
small_count
,
dup_count
,
error_count
=
[
0
]
*
4
pngdir
=
path
if
not
os
.
path
.
exists
(
path
):
sg
.
popup
(
'Duplicate Finder'
,
'** Folder doesn
\'
t exist***'
,
path
)
return
pngfiles
=
os
.
listdir
(
pngdir
)
total_files
=
len
(
pngfiles
)
for
idx
,
f
in
enumerate
(
pngfiles
):
if
not
sg
.
one_line_progress_meter
(
'Counting Duplicates'
,
idx
+
1
,
total_files
,
'Counting Duplicate Files'
):
break
total
+=
1
fname
=
os
.
path
.
join
(
pngdir
,
f
)
if
os
.
path
.
isdir
(
fname
):
continue
x
=
open
(
fname
,
"rb"
).
read
()
m
=
hashlib
.
sha256
()
m
.
update
(
x
)
f_sha
=
m
.
digest
()
if
f_sha
in
shatab
:
# uncomment next line to remove duplicate files
# os.remove(fname)
dup_count
+=
1
# sg.Print(f'Duplicate file - {f}') # cannot current use sg.Print with Progress Meter
continue
shatab
.
append
(
f_sha
)
msg
=
'{} Files processed
\n
{} Duplicates found'
.
format
(
total_files
,
dup_count
)
sg
.
popup
(
'Duplicate Finder Ended'
,
msg
)
# ====____====____==== Pseudo-MAIN program ====____====____==== #
# This is our main-alike piece of code #
# + Starts up the GUI #
# + Gets values from GUI #
# + Runs DeDupe_folder based on GUI inputs #
# ------------------------------------------------------------- #
if
__name__
==
'__main__'
:
source_folder
=
None
source_folder
=
sg
.
popup_get_folder
(
'Duplicate Finder - Count number of duplicate files'
,
'Enter path to folder you wish to find duplicates in'
)
if
source_folder
is
not
None
:
FindDuplicatesFilesInFolder
(
source_folder
)
else
:
sg
.
popup_cancel
(
'Cancelling'
,
'*** Cancelling ***'
)
exit
(
0
)
Back
|
FazBrowse Home
|
New Git URL