now getting the dirname properly from the path of the file