1

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
...
  • 1
    Yes in a script; but I can't recall how I did it (it was years ago). One way could be using 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
2

Actually no need flint. Just do md5sum and a get list of I/O errors, then process to delete those files.

~/usr/mnt5/DCIM/104APPLE$ md5sum *
md5sum: IMG_4001.JPG: Input/output error
md5sum: IMG_4002.JPG: Input/output error
md5sum: IMG_4003.JPG: Input/output error
md5sum: IMG_4004.JPG: Input/output error
md5sum: IMG_4005.JPG: Input/output error
md5sum: IMG_4006.JPG: Input/output error
md5sum: IMG_4007.JPG: Input/output error
md5sum: IMG_4008.JPG: Input/output error
md5sum: IMG_4009.JPG: Input/output error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.