-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindMissingFileNumbers.py
32 lines (29 loc) · 1.06 KB
/
FindMissingFileNumbers.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
#! /usr/bin/env/python
import mmap
import re
#-------------------------------------------------------------------------------------------
# Main Function
#-------------------------------------------------------------------------------------------
def main():
filePath = input("Enter file path: ")
endFileNum = input("Enter end file number: ")
print(filePath)
print(endFileNum)
filesMissing = []
filesPresent = []
f = open(filePath, 'rb', 0)
s = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
for x in range(int(endFileNum)):
searchString = "file" + str(x).zfill(3) + ".txt"
b = bytes(searchString, 'utf-8')
if re.search(b, s):
filesPresent.append(searchString)
else:
filesMissing.append(searchString)
print(filesPresent)
print(filesMissing)
#-------------------------------------------------------------------------------------------
# Start Main
#-------------------------------------------------------------------------------------------
if __name__ == "__main__":
main()