-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectoryEncoderOrDecoder.py
More file actions
137 lines (124 loc) · 4.48 KB
/
DirectoryEncoderOrDecoder.py
File metadata and controls
137 lines (124 loc) · 4.48 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import os
from EncoderAndDecoder import convertor, revertor, convertor_test
import pickle
Total_files = []
Total_UnEncryptable_Files = []
def dir_search(location):
change_dir = location
os.chdir(change_dir)
current_dir = os.listdir()
location = []
folders = []
for item in current_dir:
if (os.path.isdir(item)):
location.append(item)
Total_files.append(item)
# new_name = convertor(folder_name)
# os.rename(folder_name,new_name)
folders.append(item)
else:
location.append(item)
Total_files.append(item)
# new_name = convertor(file_name)
# os.rename(file_name,new_name)
print(f"\nTotal Files in '{change_dir}' = {len(location)}")
if(len(folders)!=0):
print(f"\tFolder Present in '{change_dir}' = YES \n\tTotal Amount of Folder Present = {len(folders)}")
for folder in folders:
new_dir = change_dir + "/"+ folder
dir_search(new_dir)
else:
print(f"\tFolder Present in '{change_dir}' = NO\n")
def dir_encrypt_test(location):
change_dir = location
os.chdir(change_dir)
current_dir = os.listdir()
location = []
folders = []
unEncryptable_files = []
for item in current_dir:
if(os.path.isdir(item)):
location.append(item)
test,rename_overflow = convertor_test(item)
Total_files.append(item)
folders.append(item)
if(test>0 or rename_overflow):
unEncryptable_files.append(item)
Total_UnEncryptable_Files.append(item)
else:
location.append(item)
test,rename_overflow = convertor_test(item)
Total_files.append(item)
if(test>0 or rename_overflow):
unEncryptable_files.append(item)
Total_UnEncryptable_Files.append(item)
print(f"\nTotal Files in {change_dir} = {len(location)}")
if(len(unEncryptable_files)!=0):
print(f"\tTotal UnEncryptable Files in '{change_dir}' = {len(unEncryptable_files)}")
print(f"\tTotal UnEncryptable Files are =")
for item in unEncryptable_files:
print(f"\t{item}")
print("\n")
else:
print(f"\tNo UnEncryptable Files in '{change_dir}'")
if(len(folders)!=0):
print(f"\tFolder Present in '{change_dir}' = YES \n\tTotal Amount of Folder Present = {len(folders)}")
for folder in folders:
new_dir = change_dir + "/"+ folder
dir_encrypt_test(new_dir)
else:
print(f"\tFolder Present in '{change_dir}' = NO\n")
def dir_encrypt(location):
change_dir = location
os.chdir(change_dir)
current_dir = os.listdir()
location = []
folders = []
for item in current_dir:
if(os.path.isdir(item)):
location.append(item)
new_name = convertor(item)
Total_files.append(new_name)
folders.append(new_name)
os.rename(item,new_name)
else:
location.append(item)
Total_files.append(item)
new_name = convertor(item)
os.rename(item,new_name)
print(f"\nTotal Files in '{change_dir}' = {len(location)}")
if(len(folders)!=0):
print(f"\tFolder Present in '{change_dir}' = YES \n\tTotal Amount of Folder Present = {len(folders)}")
for folder in folders:
new_dir = change_dir + "/"+ folder
dir_encrypt(new_dir)
else:
print(f"\tFolder Present in '{change_dir}' = NO\n")
def dir_decrypt(location):
change_dir = location
os.chdir(change_dir)
current_dir = os.listdir()
location = []
folders = []
for item in current_dir:
encoded_name = item
original_name = revertor(item)
os.rename(encoded_name,original_name)
Total_files.append(item)
updated_current_dir = os.listdir()
for item in updated_current_dir:
if(os.path.isdir(item)):
folders.append(item)
if(len(folders)!=0):
print(f"Folder Present in '{change_dir}' = YES \n\tTotal Amount of Folder Present = {len(folders)}")
for folder in folders:
print(folder)
new_dir = change_dir + "/"+folder
dir_decrypt(new_dir)
else:
print(f"\tFolder Present in '{change_dir}' = NO\n")
# dir_search(user_dir)
# dir_encoder(user_dir)
# dir_decoder(user_dir)
# pickle_in = open("All File Names Here.pickle","wb")
# pickle.dump(Total_files,pickle_in)