-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirSearch.py
More file actions
30 lines (26 loc) · 1.01 KB
/
dirSearch.py
File metadata and controls
30 lines (26 loc) · 1.01 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
import glob
import os
import os.path, time
from datetime import datetime
pattern = '/SNS/SNAP/shared/Calibration/**/1010/config1010*.json'
FindMostRecent = False
refDate = datetime.now().timestamp()
for fname in glob.glob(pattern, recursive=True):
ShortestTimeDifference = 10000000000 # a large number of seconds
if os.path.isfile(fname):
#rint(fname)
#print("Created: %s" % time.ctime(os.path.getctime(fname)))
#print('epoch:',os.path.getctime(fname))
#print('refdate epoch:',refDate)
delta = refDate - os.path.getctime(fname)
#print('difference:',delta)
if delta <= ShortestTimeDifference:
MostRecentFile = fname
ShortestTimeDifference = delta
if ShortestTimeDifference == 10000000000:
print('no matching file found')
else:
print('Most recent matching file:',fname)
print('Created: %s'% time.ctime(os.path.getctime(fname)))
#print(refDate-vvos.path.getctime(fname))
#timestr = SetUpDate.strftime("_%d-%b-%Y-%H%M%S")