I'm writing a code in Python to list all files with their sizes and date of creation in a specific directory including its sub-directories. The code I ended up with works only for the current directory, but not for a specific directory. If I replace the value of the variable folder by a specific directory it comes up with an error.
Below is my code:
import os, sys, time
folder = "C:\ENTD261"
listOfFiles = ""
for root, dirs, files in os.walk(folder):
for list in files:
file_size = os.path.getsize(list)
createDate = time.ctime(os.path.getctime(list))
listOfFiles = list, "Size: %.1f bytes"%file_size, "Created date: " + createDate
print(listOfFiles)