-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsorter.py
More file actions
71 lines (64 loc) · 3.24 KB
/
sorter.py
File metadata and controls
71 lines (64 loc) · 3.24 KB
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
71
import subprocess,time
import os,re
path=str(input("set path for directory: "))
l=path.split()
modified="\\".join(l)
os.chdir(modified)
myset=os.listdir()
key=int(input("choose custom names(1) or default name(2) : "))
if key==2:
for elements in myset:
m=re.findall(r"([^\s]+(\.(?i)(exe|gz|zip))$)",elements)
k=re.findall(r"([^\s]+(\.(?i)(jpg|png|gif|bmp))$)",elements)
t=re.findall(r"([^\s]+(\.(?i)(json|pdf|ppt|txt))$)",elements)
if len(k)>0 and ("wallpaper" or "wallpapers") not in myset:
subprocess.call("mkdir images", shell=True)
elif len(m)>0 and ("software" or "softwares") not in myset:
subprocess.call("mkdir softwares", shell=True)
elif len(t)>0 and ("text" or "texts") not in myset:
subprocess.call("mkdir texts", shell=True )
subprocess.call("move *.exe "+modified+"\\softwares", shell=True)
subprocess.call("move *.json "+modified+"\\texts", shell=True)
subprocess.call("move *.gz "+modified+"\\softwares", shell=True)
subprocess.call("move *.zip "+modified+"\\softwares", shell=True)
subprocess.call("move *.jpg "+modified+"\\images", shell=True)
subprocess.call("move *.png "+modified+"\\images", shell=True)
subprocess.call("move *.gif "+modified+"\\images", shell=True)
subprocess.call("move *.bmp "+modified+"\\images", shell=True)
subprocess.call("move *.pdf "+modified+"\\texts", shell=True)
subprocess.call("move *.txt "+modified+"\\texts", shell=True)
subprocess.call("move *.ppt "+modified+"\\texts", shell=True)
elif key==1:
j,a,b=[],[],[]
for elements in myset:
m=re.findall(r"([^\s]+(\.(?i)(exe|gz|zip))$)",elements)
k=re.findall(r"([^\s]+(\.(?i)(jpg|png|gif|bmp))$)",elements)
t=re.findall(r"([^\s]+(\.(?i)(json|pdf|ppt|txt))$)",elements)
j.append(m)
a.append(k)
b.append(t)
if len(a)>0:
images=str(input("Enter name for image folder: "))
subprocess.call("mkdir "+images, shell=True)
subprocess.call("move *.jpg "+modified+"\\"+images, shell=True)
subprocess.call("move *.png "+modified+"\\"+images, shell=True)
subprocess.call("move *.gif "+modified+"\\"+images, shell=True)
subprocess.call("move *.bmp "+modified+"\\"+images, shell=True)
time.sleep(1)
if len(j)>0:
softwares=str(input("Enter name for software folder: "))
subprocess.call("mkdir "+softwares, shell=True)
subprocess.call("move *.exe "+modified+"\\"+softwares, shell=True)
subprocess.call("move *.gz "+modified+"\\"+softwares, shell=True)
subprocess.call("move *.zip "+modified+"\\"+softwares, shell=True)
time.sleep(1)
if len(b)>0:
texts=str(input("Enter name for texts folder: "))
subprocess.call("mkdir "+texts, shell=True)
subprocess.call("move *.pdf "+modified+"\\"+texts, shell=True)
subprocess.call("move *.txt "+modified+"\\"+texts, shell=True)
subprocess.call("move *.ppt "+modified+"\\"+texts, shell=True)
subprocess.call("move *.json "+modified+"\\"+texts, shell=True)
time.sleep(1)
else:
print("Try agin Enter valid input")