Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to delete corrupt image files in bulk not individually using Finder / Spotlight?

Hi


I am going through a few old PC hard drives using Finder & Spotlight to remove unwanted files and folders.

However, I have a hard drive with at least 40,000 corrupt photo images (no thumb nail and Photos won't open it) which I would like to delete on mass and not individually.


There are many folders as the hard drives are Windows PC backups before I moved to Mac.


Is there an easy way or script I can run to remove these useless files in one go or is it just a case of going through all the files and deleting the ones I don't want.


Thanks in advance.

Matt

macOS High Sierra (10.13.2), Final Cut X

Posted on Dec 17, 2017 1:11 PM

Reply
2 replies

Dec 17, 2017 3:35 PM in response to AppleMacCider

If you can find them all in Spotlight, you can then drag all of them to the Trash (cmd-A, Move to Trash). However, the Finder often gets bogged down if you try to delete a lot of files.


Using the Terminal would be the fastest, but also could be problematic if you mistype.


If you need to locate the files, the find command in unix is quite powerful and can be combined with an action to perform on the found files. There are lots of tutorials online.


Do you know which ones are corrupt such that you could just drag them to the Terminal or do you need to find them based on some criteria?


If you can just drag them to the Terminal window, type the remove command

rm

and leave a space. The, drag the files into the Terminal window. It will expand all of the file paths. Hit return and it will go through and delete them.

It doesn't delete directories, by default, but you can add the -d option to try to remove directories. It will only remove an empty directory. The -R option will recursively go through a directory and delete everything in it and its subfolders.

I don't know what the maximum command length is, though. You may run into problems if you drag too many deeply buried files.


If you need to find the files, then you would need to know how to identify the ones you want to delete. Find has many options to isolate the files. Once you can create a find command that can get all of the bad files, you can add the remove command to the find command and it will remove the files it finds. A lot more information would be need to create that command, though.

How to delete corrupt image files in bulk not individually using Finder / Spotlight?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.