Script now checks/makes directories inside the sort function