-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsizeFiles.py
More file actions
executable file
·38 lines (27 loc) · 1022 Bytes
/
sizeFiles.py
File metadata and controls
executable file
·38 lines (27 loc) · 1022 Bytes
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
#!/usr/bin/env python3
"""
Ausgabe der Größe aller Dateien in einem Verzeichnis.
HINWEIS: Dieses Programm wurde für die Benutzung unter Linux geschrieben!
@author: Christian Wichmann
@license: GNU GPL
"""
import os, fnmatch, shutil
app_title = "Dateigrößenberechnung"
directory = "/home/christian/"
destination = "/home/christian/temp/"
filter_string = "*.png"
count_files = 0
size_files = 0
# Banner ausgeben
print(app_title)
# Rekursiv alle Dateien suchen, die dem Filter entsprechen und die Größe aufaddieren
for root, dirnames, filenames in os.walk(directory):
for filename in fnmatch.filter(filenames, filter_string):
count_files += 1
size_files += os.path.getsize(os.path.join(root, filename))
# Datei ins Ziel kopieren
#if not os.path.exists(destination):
# os.mkdir(destination)
#shutil.copy(os.path.join(root, filename), destination)
print("Anzahl der Dateien: " + str(count_files))
print("Größe der Dateien: " + str(size_files))