-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
27 lines (22 loc) · 792 Bytes
/
main.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
import os
import shutil
def get_files():
source = os.path.expanduser("~/Downloads/")
files = os.listdir(source)
for file in files:
extension = os.path.splitext(file)[1]
extension = extension[1:]
try:
os.makedirs(source + extension)
except FileExistsError:
pass
ofiles = (file for file in os.listdir(source)
if os.path.isfile(os.path.join(source, file)))
for file in ofiles:
# go through every file in the source folder
extension = os.path.splitext(file)[1]
extension = extension[1:]
shutil.move(source + file, source + extension + '/' + file)
# move from source , every file to (for example) source/exe/filename.exe
if __name__ == '__main__':
get_files()