Can anyone help write a script, the goal is to find files with extension and save the name and path in TXT or CSV
that a script which find and print file file type and path,but how can i save the result to csv/txt ?
import fnmatch
import os
import csv
rootPath = '/'
pattern = '*.exe'
filepath = 'C:/Users/user/Desktop/filetest.txt'
for root, dirs, files in os.walk(rootPath):
for filepath in fnmatch.filter(files, pattern):
x = (os.path.join(root, filepath))
print(x)
i try this one, but its save only the last line.
import fnmatch
import os
import csv
rootPath = '/'
pattern = '*.exe'
filepath = 'C:/Users/user/Desktop/filetest.txt'
for root, dirs, files in os.walk(rootPath):
for filepath in fnmatch.filter(files, pattern):
x = (os.path.join(root, filepath))
file = open(filepath, 'w')
file.write(x)
file.close()
print(x)