How do you delete a file that is not deleting?

Deleting a file that won’t delete can be frustrating. There are a few potential reasons why a file may not be deleting properly and several methods you can try to force delete the stubborn file.

Quick Overview

Here is a quick overview of the common reasons a file might not delete and solutions to try:

  • The file is in use or open – Close any programs using the file and try deleting again
  • Insufficient permissions – Try deleting as an admin or taking ownership of the file first
  • The file is read-only – Remove the read-only attribute and try deleting again
  • The file is corrupted – Try using a third party deletion tool like Unlocker to force delete
  • Antivirus software is blocking deletion – Add an exception or temporarily disable antivirus
  • The delete command is not being executed – Double check you are permanently deleting vs sending to Recycle Bin

Common Reasons a File Won’t Delete

There are several common reasons why a file may fail to delete or seem to be undeletable:

The File is in Use or Open

One of the most common reasons a file can’t be deleted is because it is still in use or open by a program. As long as the file is still open, it will be locked by the operating system and unable to be deleted.

Before trying to delete a file, close any programs that may be using that file. This includes applications like Word or Excel that may have the file open for editing, a media player using the file, an email client with the file attachment open, etc. Close all applications entirely and try deleting again.

Insufficient Permissions to Delete File

Another reason a file cannot be deleted is due to permissions settings preventing you from deleting the file. On Windows, you may encounter files that require administrator access to delete. Other users’ files may also block you from deleting them if your user account does not have the right permissions.

Try deleting the file from an administrator account instead. On Windows, right click the file, select “Run as administrator” then try deleting. On Mac, add “sudo” before your delete command in Terminal to run as root.

You can also try taking ownership of the file first before deleting. This can override permissions that may be blocking a standard user from deleting the file.

The File is Marked Read-Only

If a file has the read-only attribute enabled, most delete commands will fail. The file essentially becomes undeletable while read-only is enabled.

To check for this, right click the file, select Properties, and look for the Read-only checkbox. Uncheck it, click OK, then try deleting the file again. This will remove the restriction preventing deletion.

The File is Corrupted

In some cases, a file can become corrupted or damaged in a way that makes it impossible to properly delete by normal means. The file system may refuse to delete the file or be unable to completely remove it from the disk.

Using a dedicated file deletion tool like Unlocker can help force deletion of corrupted files. The tool can skirt around issues like corruption and access problems to completely wipe the file from the system.

Antivirus Software is Blocking Deletion

Security software like antivirus or anti-malware tools can sometimes interfere with deleting files. The protection tools may suspect the file is malicious and block access to delete it.

Try temporarily disabling your antivirus or anti-malware program and attempt deleting the file again. Or you can add the file as an exclusion if you are certain it is safe, then retry deleting.

The Delete Command is Not Permanent

Another potential mistake is trying to permanently delete a file using a command that is only designed to move it to the Recycle Bin or Trash. For example, using a simple delete key press or drag and drop to the Trash.

Make sure you are using a command that will permanently wipe the file from the hard drive without the option to recover from the Recycle Bin. On Windows, use Shift+Delete. On Mac, empty the Trash first then use ⌘ + Delete.

Force Deleting an Undeletable File on Windows

If you have tried the typical solutions and the file still will not delete normally, here are some methods to force delete the stubborn file on Windows:

Delete from Command Prompt

Using the Command Prompt to delete the file may be more effective than standard graphical delete methods. The Command Prompt runs with administrator access so it can override some permissions issues.

Open Command Prompt as admin then run:

del /f /q “filepath”

This will force deletion (/f) of the file without confirmation (/q).

Unlocker

Unlocker is a free utility specifically designed to force delete files that refuse to be removed normally. It can delete files that are in use, locked, have permissions issues, or are corrupted.

Download Unlocker, right click on the stuck file, choose Unlocker, then select Delete. It will automatically force delete the file for you.

Delete with Piriform Recuva

The file recovery tool Recuva from Piriform can also delete undeletable files in its secure overwrite function. Recuva overwrites the data to ensure it can’t be recovered.

  1. Download and install Recuva.
  2. Run Recuva and click the Secure Overwrite option.
  3. Choose the Common or DOD standard overwrite method.
  4. Locate and select the file to destroy.
  5. Click Overwrite to securely shred the file.

Use Windows File Explorer

The built-in File Explorer in Windows also has an effective delete option that may succeed when others fail. The entire folder containing the file can be deleted to remove the stuck file.

  1. Open File Explorer and navigate to the folder with the file.
  2. Right click on the folder and choose Delete.
  3. Check the box that says “Delete this folder and all subfolders and files” then confirm deletion.

This will recursively delete everything in that folder, including the stuck file.

Force Deleting an Undeletable File on Mac

On a Mac, here are some terminal commands and methods to try forcing deletion of a stubborn file that won’t delete normally:

Use Terminal

The Terminal app provides access to powerful command line options that can force delete just about anything. Here are some terminal commands to try:

sudo rm -rf filepath

Runs the remove command with root access to override permissions.

sudo chflags nohidden filepath

Removes the hidden flag if set on the file.

sudo chflags noschg filepath

Removes the system immutable flag if set.

Try Secure Empty Trash

If the file is already in the Trash, you can try securely emptying the Trash to force deletion.

  1. Open the Trash folder
  2. Right click on the Trash icon and choose Empty Trash.
  3. Select the “Securely remove items” option then confirm.

This will attempt to completely remove everything in Trash without the option to recover.

Use a Third Party Tool

Specialty Mac file deletion tools can help in stubborn cases where normal delete methods fail. Some options include:

  • AppCleaner – Freeware app to force delete stuck files.
  • DeleteFile – Small tool to securely overwrite then delete files.
  • ShredIt X – Deletes files then overwrites space for security.

These tools can circumvent the standard deletion methods to ensure a file gets permanently removed.

Preventing Undeletable Files

To avoid dealing with undeletable files in the future, here are some tips:

  • Close applications before deleting files in use
  • Delete files as soon as you no longer need them
  • Avoid setting read-only permissions on files unless necessary
  • Have a good malware and antivirus scanner to prevent corrupted files
  • Use the Shift+Delete or Empty Trash commands to permanently delete files

Practicing good file management hygiene will minimize the chances of a file becoming stuck and undeleteable down the road.

Recovering a Deleted File

If you find that you accidentally deleted an important file, there may still be a chance to recover it:

Restore from Recycle Bin / Trash

If the file is still in the Recycle Bin or Trash folder, restore it from there back to its original location.

Use Recovery Software

Programs like Recuva or Disk Drill can scan the hard drive and restore deleted files that weren’t securely overwritten. This can rescue files deleted accidentally.

Restore from Backup

If you have another copy of the file in a backup or cloud storage, you can restore the deleted file from there.

Prevention is key, but recovery is possible in some cases if an important file was mistakenly deleted.

Conclusion

Deleting a stubborn file that refuses normal deletion methods can be a challenge. By understanding the potential causes and employing the right force delete techniques, you can remove even the most undeleteable file. Paying attention to file permissions, avoiding corruption, and deleting responsibly will also help minimize undeletable file headaches down the road.