Sometimes what happens is that due to virus attack data or files within the Pen drive it get hidden. So before formatting, your pen try to unhide the files which occupying the space of the pen drive. You can try to type dot asterisk in the search bar .* to unhide the files and you can see it. if does not work then
to recover files due to virus attack CMD scripting as
1. Plug in your Pen drive to your computer
2. Go to the start menu, type in "cmd" in a search bar, hit enter and then you can see something named "cmd. exe"
under a list of programs.
3. Right-click "cmd. exe" and then you will get the command windows that allows you to recover virus infected files. Type
in "attrib -h -r -s /s /d drive letter:\*.*", for example, "attrib -h -r -s /s /d G:\*.*".
I hope this would help.