How to delete a corrupted file Mac

Remove DS_Store Files on macOS

OneDrive (work or school) OneDrive (home or personal) More...Less

Corrupted .DS_Store files can prevent OneDrive from syncing correctly. Deleting the corrupted files can help restore normal sync operation.

No data is lost by deleting the corrupted files as Mac Finder only creates .DS_Store files to store viewing options, such as the positions of icons, size of the Finder window, and window backgrounds.

  1. To delete a corrupted .DS_Store file, you will need to use Terminal.app.

    Note: You must be logged into macOS as an administrator.

    1. Open a new Finder window and navigate to the Applications folder on the left.

    2. Open the Utilities folder, then double-click the Terminal application.

  2. Give yourself super-user (root) permissions in Terminal so you can use the commands needed to delete .DS_Store files. 

    1. In Terminal, type sudo ls then press Return on your keyboard.

    2. When Terminal prompts you for a password, enter your administrator account password. If you don't have a password, leave it blank.

      Note: For security reasons, macOS won't show any sign that you are typing your password. Just type normally, even though nothing shows.

  3. Navigate to the folder that is not syncing correctly.

    1. In Terminal, type cd followed by a space.

    2. Find the folder with the issue but do not open it. Instead, drag its icon into Terminal and watch it complete the path for you, then press Return.

  4. Remove the .DS_Store folder and all its contents.

    Caution: Make sure you are deleting the correct folder.

    Type rm -f .DS_Store and press Return.

    Note: Terminal will give no indication that this has been completed. It will only return a message if the command did not work.

Need more help?

Need more help?

Short answer: yes, almost any changes you make on the disk have a possibility of causing further damage. Back up anything important (making minimal changes as you do so), then try to diagnose and fix it.

Long answer: there are several different levels where you could have data corruption/damage:

  1. There might be a hardware problem -- failing drive, bad cable, etc. I'm not familiar enough with the failure modes of SSDs to tell if this might be the problem here, but I wouldn't rule it out.
  2. The filesystem data structures (which keep track of what files exist on the disk, where their data is stored, which blocks are available for use, etc) might be corrupted. This sort of damage sort-of applies to the entire volume (or container, in the case of APFS), but might only affect some files/folders.
  3. Some individual files might have damaged/corrupted contents. I don't think that's the problem here, since a Finder copy will just blindly copy the contents, whether or not they make sense.

Problems at any of these levels can cause secondary problems at higher levels. Hardware problems can cause volume data and/or file contents to get garbled, and volume problems can cause things like parts of files getting overwritten or lost. So if you see problems at one level, keep in mind that the root cause might be at a lower level.

Conversely, trying to fix (or just change) things at a higher level than the root cause can cause additional damage. If you've got damaged volume data structures, creating, deleting, or even editing files can cause the damage to snowball. If you have a hardware problem, trying to repair the volume data structures (e.g. with Disk Utility's First Aid feature) might just cause additional secondary problems at that level.

In your situation, the first thing I'd do is make sure any important files/data is backed up (or as sure as possible under the circumstances). If possible, do this while booted from something else, with the suspect volume mounted read-only to avoid further corruption. (That's probably not possible, so don't worry about it too much. But don't make any unnecessary changes on the disk until the backup's done.)

Then and only then, try running hardware tests, like Apple Hardware Test (for models introduced before June 2013) or Apple Hardware Diagnostics (for models introduced after June 2013) (more info here), or a third-party test utility.

If the hardware tests don't find anything wrong, then start looking at the volume data structures. I don't have any experience repairing APFS yet, but I'd try Disk Utility First Aid first (probably booted in recovery mode). Frankly, if that can't fix it, I'd erase the disk (not just the volume) and reinstall/recover from scratch.

Afterward, maintain good ongoing backups in case there's some underlying problem that didn't get detected/fixed.

How do I delete a corrupt file on Mac?

Log into your account and locate the file you want to delete. Since your Mac is in Safe Mode, you might be able to delete the corrupted file. Drag the file to the Trash. You can also click to select the file in Finder, then go up to the menu and select Move to Trash.

How do I force a corrupted file to delete?

Type the following command Del /F /Q /A < file path > and press Enter..
"/F" means to force delete files..
"/Q" means to delete read-only files,.
"/A" means to select files with the archiving attribute..
< file path > is the corrupted file's location. For example, you might have "Del /F /Q /A C:\Users\XXX\Downloads"..

How do you force delete a file that won't Delete on a Mac?

When a file is locked, you need to unlock it first in order to move to Trash..
Ctrl-click the file you cannot delete and select Get Info..
Expand the General tab and find the Locked checkbox. Deselect it if it's turned on..
Go back to select the file and delete it again..

How do I repair a corrupted file on a Mac?

Mac's Built-In Repair Shop Open up your Applications folder, and click “Utilities.” Open up the Disk Utility application in that list to have access to the repair tool. Now simply drag your damaged DMG file onto the Disk Utility window. Click the damaged file, and then select “Repair Disk” in the First Aid tab.