Use dirname to make the directory, not basename.