forked from shimonShouei/NvdScannerRezilion
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_files_programfiles.py
More file actions
35 lines (30 loc) · 1.21 KB
/
get_files_programfiles.py
File metadata and controls
35 lines (30 loc) · 1.21 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
from os import listdir
from os.path import isfile, join
import os
import shutil
def get_file_from_path(name_software):
list_of_path_directory = []
list_of_path_files = []
path_ = ["C:\Program Files\\", "C:\Program Files (x86)\\"]
for i in path_:
for neighbour in os.listdir(i):
if name_software.__contains__(neighbour):
name_software = neighbour
path = ["C:\Program Files\\"+name_software, "C:\Program Files (x86)\\"+name_software]
for i in path:
get_file_from_path_by_dfs(list_of_path_directory, list_of_path_files, i)
print(list_of_path_files)
return list_of_path_files
def get_file_from_path_by_dfs(list_of_path_directory, list_of_path_files, path):
if os.path.isdir(path) and path not in list_of_path_directory:
list_of_path_directory.append(path)
for neighbour in os.listdir(path):
try:
get_file_from_path_by_dfs(list_of_path_directory, list_of_path_files, path + "\\" + neighbour)
except PermissionError:
pass
# check if thia path is file
elif os.path.isfile(path) and path not in list_of_path_files:
list_of_path_files.append(path)
else:
pass