Normal file managers and the "cp" command give up at the first I/O error.
There is already "ddrescue", but that is not pre-installed on most systems and you might not have Internet access that is needed to download ddrescue, so this is what you can do with the pre-installed "dd":
First, create a recovery directory:
Then, create a blank reference file with the same size of the damaged file.
Code:
truncate --reference=damaged.mp3 ~/recovered/damaged.mp3
Then recover the damaged file:
Code:
dd if=damaged.mp3 of=~/recovered/damaged_file.mp3 conv=sync,notrunc,noerror ibs=2048
The "noerror" option, as you might guess, tells dd not to give up when encountering an I/O error.
The "sync" option fills unreadable sectors with null bytes (00) in the output file so the readable parts of the data in the output file are aligned with the input file. This is necessary for some file types such as WMA. Unlike MP3 files, WMA files are unplayable if the data is misaligned.
The "notrunc" option prevents the output file "~/recovered/damaged_file.mp3" from being reset to zero size when the recovery process starts.
Values for ibs=: 2048 or 2K for optical discs (CD, DVD, BluRay), 512 for small flash media (USB sticks, SD and MicroSD cards), 4096 or 4K for large external media (SSD, HDD).