I'm trying to check the file size of a bunch of files from a specific directory, but not being able, could you guys help me?
import os
dir_path = 'C:\\temp\\cmm_temp\\tmp\\'
files = os.listdir(dir_path)
with open(dir_path+files, "r") as arq:
for arq in files:
file_size = os.stat(str(arq)).st_size
if file_size == 0:
print("The file is empty: "+str(arq) + str(file_size))
else:
print("The file is not empty: " +str(arq) + str(file_size))
that's the output
C:\USER_ATU\PycharmProjects\CMM_SDL157\venv\Scripts\python.exe C:/USER_ATU/PycharmProjects/CMM_SDL157/venv/Scripts/testFile.py
Traceback (most recent call last):
File "C:/USER_ATU/PycharmProjects/CMM_SDL157/venv/Scripts/testFile.py", line 35, in <module>
with open(dir_path+files, "r") as arq:
FileNotFoundError: [Errno 2] No such file or directory: "C:\\temp\\cmm_temp\\tmp\\['MST_DatFileList.txt', 'MST_TtsFileParsed.txt', 'test_fileZero.txt', 'ZTN_DatFileList.txt', 'ZTN_TtsFileParsed.txt']"
Process finished with exit code 1
Thanks