-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain3.py
More file actions
32 lines (30 loc) · 945 Bytes
/
Copy pathmain3.py
File metadata and controls
32 lines (30 loc) · 945 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
import os
def duzenle():
klasor = input("Düzenlenecek klasor:")
dosyalar= []
uzantilar = []
def list_dir():
for dosya in os.listdir(klasor):
if os.path.isdir(os.path.join(klasor, dosya)):
continue
if dosya.startswith("."):
continue
else:
dosyalar.append(dosya)
list_dir()
for dosya in dosyalar:
uzanti = dosya.split(".")[-1]
if uzanti in uzantilar:
continue
else:
uzantilar.append(uzanti)
for uzanti in uzantilar:
if os.path.isdir(os.path.join(klasor,uzanti)):
continue
else:
os.mkdir(os.path.join(klasor,uzanti))
for dosya in dosyalar:
uzanti = dosya.split(".")[-1]
os.rename(os.path.join(klasor, dosya),os.path.join(klasor,uzanti, dosya))
if __name__ == ("__main__"):
duzenle()