I'm using a python class made from the SDK. (https://www.voidtools.com/support/every ... dk/python/) and I'm pretty happy with it.
The filter "folder: d:\" returns 9,496 items in 0.010 seconds, which is acceptable.
The filter "folder: d:\ !attrib:H" returns 9,478 items in 0.276 seconds, which is much to slow. (Drive C: is 30 times as big)
Shell Attributes are included in the properties for files and folders.
What am I missing?
Thanx fore reading, Laus
BTW: Everything 1.5 alpha, python 3.11.2, W10,
In the Everything GUI the results appear instantly.
Here's my module:
Code: Select all
import datetime
import struct
import ctypes
class everything:
# search everything database for full qualified filenames matching a search phrase
def __init__(self, everything_path = r"C:\Program Files\Everything\Everything64.dll"):
'''Init "Everything". Optionally give a full qualified file name of everything.dll'''
#defines
self.EVERYTHING_REQUEST_FILE_NAME = 0x00000001
self.EVERYTHING_REQUEST_PATH = 0x00000002
self.EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME = 0x00000004
self.EVERYTHING_REQUEST_EXTENSION = 0x00000008
self.EVERYTHING_REQUEST_SIZE = 0x00000010
self.EVERYTHING_REQUEST_DATE_CREATED = 0x00000020
self.EVERYTHING_REQUEST_DATE_MODIFIED = 0x00000040
self.EVERYTHING_REQUEST_DATE_ACCESSED = 0x00000080
self.EVERYTHING_REQUEST_ATTRIBUTES = 0x00000100
self.EVERYTHING_REQUEST_FILE_LIST_FILE_NAME = 0x00000200
self.EVERYTHING_REQUEST_RUN_COUNT = 0x00000400
self.EVERYTHING_REQUEST_DATE_RUN = 0x00000800
self.EVERYTHING_REQUEST_DATE_RECENTLY_CHANGED = 0x00001000
self.EVERYTHING_REQUEST_HIGHLIGHTED_FILE_NAME = 0x00002000
self.EVERYTHING_REQUEST_HIGHLIGHTED_PATH = 0x00004000
self.EVERYTHING_REQUEST_HIGHLIGHTED_FULL_PATH_AND_FILE_NAME = 0x00008000
#dll imports
self.everything_dll = ctypes.WinDLL (everything_path)
self.everything_dll.Everything_GetResultDateModified.argtypes = [ctypes.c_int,ctypes.POINTER(ctypes.c_ulonglong)]
self.everything_dll.Everything_GetResultSize.argtypes = [ctypes.c_int,ctypes.POINTER(ctypes.c_ulonglong)]
#convert a windows FILETIME to a python datetime
#https://stackoverflow.com/questions/39481221/convert-datetime-back-to-windows-64-bit-filetime
self.WINDOWS_TICKS = int(1/10**-7) # 10,000,000 (100 nanoseconds or .1 microseconds)
self.WINDOWS_EPOCH = datetime.datetime.strptime('1601-01-01 00:00:00','%Y-%m-%d %H:%M:%S')
self.POSIX_EPOCH = datetime.datetime.strptime('1970-01-01 00:00:00','%Y-%m-%d %H:%M:%S')
self.EPOCH_DIFF = (self.POSIX_EPOCH - self.WINDOWS_EPOCH).total_seconds() # 11644473600.0
self.WINDOWS_TICKS_TO_POSIX_EPOCH = self.EPOCH_DIFF * self.WINDOWS_TICKS # 116444736000000000.0
#create buffers
self.filename = ctypes.create_unicode_buffer(260)
self.date_modified_filetime = ctypes.c_ulonglong(1)
self.file_size = ctypes.c_ulonglong(1)
def get_time(self, filetime):
'''Convert windows filetime winticks to python datetime.datetime.'''
winticks = struct.unpack('<Q', filetime)[0]
microsecs = (winticks - self.WINDOWS_TICKS_TO_POSIX_EPOCH) / self.WINDOWS_TICKS
return datetime.datetime.fromtimestamp(microsecs)
def search(self, phrase, maxresults = 0, sorting = 2):
'''search the Everything database for phrase
read https://www.voidtools.com/support/everything/searching/
for syntax '''
if self.everything_dll.Everything_IsDBLoaded():
# maxresulte macht bei meheren Aufrufen und anschließendem Vergleich der Ergebnisse
# keinen Sinn!
if maxresults > 0:
self.everything_dll.Everything_SetMax(maxresults)
# sorting values read this :https://www.voidtools.com/support/everything/sdk/everything_setsort/
self.everything_dll.Everything_SetSort(sorting)
#setup search
self.everything_dll.Everything_SetSearchW(phrase)
#self.everything_dll.Everything_SetRequestFlags(self.EVERYTHING_REQUEST_FILE_NAME | self.EVERYTHING_REQUEST_PATH | self.EVERYTHING_REQUEST_SIZE | self.EVERYTHING_REQUEST_DATE_MODIFIED)
self.everything_dll.Everything_SetRequestFlags(self.EVERYTHING_REQUEST_FILE_NAME | self.EVERYTHING_REQUEST_PATH)
# execute the query
self.everything_dll.Everything_QueryW(1)
# get the number of results
self.num_results = self.everything_dll.Everything_GetNumResults()
self.items = []
for i in range (self.num_results):
self.everything_dll.Everything_GetResultFullPathNameW(i,self.filename,260)
self.items.append(self.filename.value)
else:
r = self.everything_dll.Everything_GetLastError()
# 2: Everything is not running
self.num_results = False
return self.num_results
if __name__ == "__main__":
import time
EVT = everything()
filters = [r"folder:d:", r"folder:d:\ !attrib:H"]
for filter in filters:
_time = time.time()
EVT.search(filter)
_time = time.time() - _time
print(f"\nroot: {filter}")
if EVT.num_results:
print(f"num:{EVT.num_results}, time:{_time}sec")
else:
print(f"nothing found, time:{_time}sec")