How i can log various information of files in directory?
I am not sure if you need to have it in this particular way, but why not simply using something like

ls -l &gt; logfile.txt


and add the necessary options to ls if you want it a little bit more specific