If I suspect errors on card I use first (full) format on laptop with
SD Memory Card Formatter | SD Association to get it back to SD-standards. Note that it is not always the same if you use the laptop Windows or MacOs format routine...
Afterwards you can still do format in camera but I think it creates anyway the camera folders on a new (or new formatted) card.
Should solve most errors (caused by software or incorrect manipulation). If the full format fails, i suggest to dump the card...as it indicates hardware errors. Some format tools try to block faulty sectors so that remaining memory can be used, but it is not a good sign ... maybe okay as temporary workaround but not for longterm reliable photoshooting.