Fixes an "off-by-one" error in file renaming

When renaming files because of duplicates, the basename of the file was
being truncated too short.