Use correct error message when renaming/deleting folder

This is for #8003.
This If chain will look better as a switch.