-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean_ids.py
35 lines (28 loc) · 1.29 KB
/
clean_ids.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
28
29
30
31
32
33
34
35
import os
def extract_vulnerable_ids_from_filenames(folder_path):
vulnerable_ids = []
for root, _, files in os.walk(folder_path):
for filename in files:
file_path = os.path.join(root, filename)
if os.path.isfile(file_path):
try:
vulnerable_id = int(filename.split(" - ")[0])
vulnerable_ids.append(vulnerable_id)
except (ValueError, IndexError):
pass
return vulnerable_ids
def save_extracted_vulnerable_ids(vulnerable_ids, output_file_path):
with open(output_file_path, "w", encoding="utf-8") as file:
for id in vulnerable_ids:
file.write(f"Vulnerable ID: {id}\n")
def main():
# Specify the folder path where the remaining files are located
remaining_files_folder_path = "C:/Users/aymen/Desktop/foundings"
# Specify the output file path
output_file_path = "C:/Users/aymen/Desktop/foundings/extracted_vulnerable_ids.txt"
# Extract vulnerable IDs from filenames
extracted_vulnerable_ids = extract_vulnerable_ids_from_filenames(remaining_files_folder_path)
# Save extracted vulnerable IDs to the specified file
save_extracted_vulnerable_ids(extracted_vulnerable_ids, output_file_path)
if __name__ == "__main__":
main()