correctly remove suffix from filenames