Hi, That is the way to repair any flash memory, if the fault is because of a software failure. Which means a corruption of a program or files or the structure of it.
It won't fix issues with the electronics which are embedded in the PCB that control the way the memory is used, if that's faulty then it's finished.
It's worth noting that you can't defrag flash memory either.
The better way to 'clean up' flash memory is to copy the entire flash memory contents/files/folders to a hard drive. Format the flash memory, then copy the original files back onto the flash memory again. That way all the free space will be together, not spread all over the memory chip.