Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.

Commit 760b764

Browse files
authoredJun 24, 2020
Merge pull request #14 from Mitesh2499/development
Development
2 parents a58b8d6 + 910adf5 commit 760b764

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed
 
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import random
2+
import math
3+
alpha="abcdefghijklmnopqrstuvwxyz"
4+
num="0123456789"
5+
special="@#$%&*"
6+
7+
#pass_len=random.randint(8,13) #without User INput
8+
pass_len=int(input("Enter Password Length"))
9+
10+
#length of password by 50-30-20 formula
11+
alpha_len=pass_len//2
12+
num_len=math.ceil(pass_len*30/100)
13+
special_len=pass_len-(alpha_len+num_len)
14+
15+
16+
password=[]
17+
18+
def generate_pass(length,array,is_alpha=False):
19+
20+
for i in range(length):
21+
index=random.randint(0,len(array)-1)
22+
character=array[index]
23+
if is_alpha==True:
24+
25+
case=random.randint(0,1)
26+
if case==1:
27+
character=character.upper()
28+
29+
password.append(character)
30+
31+
#alpha password
32+
generate_pass(alpha_len,alpha,True)
33+
#numeric password
34+
generate_pass(num_len,num)
35+
#special Character password
36+
generate_pass(special_len,special)
37+
38+
#suffle the generated password list
39+
random.shuffle(password)
40+
41+
#convert List To string
42+
gen_password=""
43+
for i in password:
44+
gen_password=gen_password+str(i)
45+
46+
print(gen_password)
47+
48+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Files-Sorter
2+
This is python script that sort the files in Download directory to other directories depending on extention.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import os
2+
import shutil
3+
os.chdir("E:\downloads")
4+
#print(os.getcwd())
5+
6+
#check number of files in directory
7+
files = os.listdir()
8+
9+
#list of extension (You can add more if you want)
10+
extentions = {
11+
"images": [".jpg", ".png", ".jpeg", ".gif"],
12+
"videos": [".mp4", ".mkv"],
13+
"musics": [".mp3", ".wav"],
14+
"zip": [".zip", ".tgz", ".rar", ".tar"],
15+
"documents": [".pdf", ".docx", ".csv", ".xlsx", ".pptx", ".doc", ".ppt", ".xls"],
16+
"setup": [".msi", ".exe"],
17+
"programs": [".py", ".c", ".cpp", ".php", ".C", ".CPP"],
18+
"design": [".xd", ".psd"]
19+
20+
21+
}
22+
23+
24+
#sort to specific folder depend on extenstions
25+
def sorting(file):
26+
keys = list(extentions.keys())
27+
for key in keys:
28+
for ext in extentions[key]:
29+
# print(ext)
30+
if file.endswith(ext):
31+
return key
32+
33+
34+
#iterat through each file
35+
for file in files:
36+
dist = sorting(file)
37+
if dist:
38+
try:
39+
shutil.move(file, "../download-sorting/" + dist)
40+
except:
41+
print(file + " is already exist")
42+
else:
43+
try:
44+
shutil.move(file, "../download-sorting/others")
45+
except:
46+
print(file + " is already exist")

0 commit comments

Comments
 (0)