Testing could be done on this method as a bleck box which should provide correct monitoring output for files,dirs,..
For me multiple functions are causing spagetty code which is not clear and hard to follow.
At my work we moved to big methods code rather then splitting to micro function code