-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathchecker.py
44 lines (28 loc) · 814 Bytes
/
checker.py
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
from tkinter import *
from tkinter import filedialog
import os
root = Tk()
root.title("Check Number Of Files...")
root.iconbitmap('c:/tkinter.com/codemy.ico')
root.geometry('500x350')
def checker():
# Create counters
file_count = 0
dir_count = 0
# Choose Directory
input_path = filedialog.askdirectory()
# Loop and count files
for root, dirs, files in os.walk(input_path):
# Count files
for file in files:
file_count += 1
# Count Dirs
for dir1 in dirs:
dir_count +=1
# Update our Label
my_label.config(text=f'Number Of Files: {file_count}\nNumber of Dirs: {dir_count}')
my_label = Label(root, text="Number of Files: ", font=("Helvetica", 28))
my_label.pack(pady=50)
my_button = Button(root, text='Check Number Of Files', command=checker)
my_button.pack()
root.mainloop()