-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetFileNames.py
36 lines (30 loc) · 1.07 KB
/
getFileNames.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
36
import os, pyautogui
sep = ['backup files\\', 'prajwal_files\\']
for i in range(2):
ext = input('Which file extension would you like to search for? > ')
folder = input('Which directory should I search? > ')
save = input('Where should I save the file? > ')
fl = open(os.path.join(save, 'files.txt'), 'w')
# fl.write('Files ending with %s in %s\n\n' %(ext, folder))
for r, d, f in os.walk(folder):
for file in f:
# if file.endswith('.txt') or file.endswith('.py'):
print(os.path.join(r, file))
text = list(os.path.join(r, file).partition(sep[i]))
del text[:2]
text = ''.join(text)
fl.write(text + '\n')
fl.close()
# f = open('c:\\users\\findp\\files.txt')
# for file in f.read().split(' '):
# try:
# fl = open(file)
# print(file + '\n\n')
# print('-' * 100)
# print(fl.read())
# print('-' * 100)
# input('Next? ')
# #pyautogui.press('enter')
# except:
# print('Error on file %s' %(file))
# continue