Announcement: Upgrade to macOS Mojave

With features like Dark Mode, Stacks, and four new built-in apps, macOS Mojave helps you get more out of every click. 
Find out how to upgrade to macOS Mojave > https://support.apple.com/macos/mojave

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

Question:

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

Reply

Dec 17, 2017 3:35 PM in response to AppleMacCider 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.

Dec 17, 2017 3:35 PM

Reply Helpful

Dec 19, 2017 2:49 PM in response to Barney-15E In response to Barney-15E

Thanks Barney-1SE


Its not going to be an easy task. I know know of the specific folders the photos are in as they are showing up in many when doing Spotlight searches. Thanks for your thought. I think its going to be a lot of coffees, time and patience to go through and delete them. Your comments are appreciated really appreciated🙂.

Dec 19, 2017 2:49 PM

Reply Helpful
User profile for user: AppleMacCider

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