Use correct error message when renaming/deleting folder

This is for #8003.