Function to check and format directories and files

 - implemented by utils.check_dir() and utils.check_file()
 - code has been converted to support these checks