I tried to mount iOS device on Ubuntu to copy/backup images. The DCIM folder has lots of files. For some reason, many of them has "Failed to open file (Input/output error)" error when trying to open them. They are intermingled with good files.
I want to delete all those image files with those errors, but don't want to go through them one by one to find out what file is good and what file cannot be opened.
Is there a way to detect those bad files from command lines?
~/usr/mnt/DCIM/101APPLE$ ll -1rth
total 614M
-rw-r--r-- 2 gdhp gdhp 2.1M May 4 13:01 IMG_1568.JPG
-rw-r--r-- 2 gdhp gdhp 1.7M May 4 13:01 IMG_1562.JPG
-rw-r--r-- 2 gdhp gdhp 3.8M May 4 13:01 IMG_1063.JPG
-rw-r--r-- 2 gdhp gdhp 1.4M May 4 13:04 IMG_1816.JPG
-rw-r--r-- 2 gdhp gdhp 190K May 4 13:04 IMG_1517.JPG # bad I/O
-rw-r--r-- 2 gdhp gdhp 1.3M May 4 13:06 IMG_1811.JPG
-rw-r--r-- 2 gdhp gdhp 668K May 4 13:06 IMG_1263.JPG
-rw-r--r-- 2 gdhp gdhp 1.3M May 4 13:06 IMG_1048.JPG
-rw-r--r-- 2 gdhp gdhp 3.0M May 16 11:20 IMG_1172.JPG # bad I/O
-rw-r--r-- 2 gdhp gdhp 2.6M May 16 11:21 IMG_1175.JPG
-rw-r--r-- 2 gdhp gdhp 1.5M May 17 18:29 IMG_1727.PNG
...
badblocks
to create a list of bad inodes, then from that list create a list of files that have used (data stored in) those inodes; but I don't recall if that's how I did it in my script. If you want to script it, this may be helpful. – guiverc Jul 13 at 4:35