This script is used to get the size of the file.Change the size of the file to be evaluated
Parameters :
Provide your folder path in Folder_Path in the script (e.g) Folder_path = "C:\\Users\\user1\\Downloads"
Provide the size of the file in file_size in the script in KB (e.g) file_size = 5000
Note:
Run as Local System User.
It should be Run as System User.
Folder_path = 'C:\\Users\\user1\\Downloads' ## Provide your folder path here where you want to find your files with size
file_size = 5000 ## provide your size of the file or larger than the size of file to be found
import ctypes
class disable_file_system_redirection:
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
def __enter__(self):
self.old_value = ctypes.c_long()
self.success = self._disable(ctypes.byref(self.old_value))
def __exit__(self, type, value, traceback):
if self.success:
self._revert(self.old_value)
with disable_file_system_redirection():
def findFilesBySizeKB(recPath, limit):
import os
ls = []
if os.path.exists(recPath):
for root, dirs, files in os.walk(recPath):
for fname in files:
fsize = os.path.getsize(os.path.join(root, fname))/1024
if fsize >= limit:
ls.append(fname+' '+str(fsize)+'KB')
return ls
if __name__=='__main__':
c = 0
print 'File Name: '
for i in findFilesBySizeKB(Folder_path, int(file_size)):
print i
c += 1
print '\n'
print 'Number of Files: ',c
Comments