handle more errors, can now receive a filename or a directory
rename