Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

If a file will not delete normally, first close any application using it and verify the exact path. Then use the command for your operating system: del /f /a on Windows Command Prompt, Remove-Item -LiteralPath ... -Force in PowerShell, or rm -f -- on macOS and Linux.

Force deletion is not a universal unlock. These commands can bypass read-only attributes, hidden-file handling, prompts, and—when explicitly requested—directory recursion. They may not remove files locked by another process, protected operating-system files, objects on read-only or failing drives, or cloud-managed items.

Check the target before pressing Enter. Force-delete commands can bypass the Recycle Bin or Trash, and recursive commands can remove an entire directory tree. Copy the complete path, confirm the filename and extension, verify whether it is a file or folder, and avoid broad wildcards until you understand exactly what they match.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick commands

Replace each example path with the exact path to your item. Keep the quotation marks when the path contains spaces.

#1 Best Overall
Sandisk 2TB Extreme Portable SSD, Up to 1050MB/s, USB-C, USB 3.2 Gen 2, IP65 Water and Dust Resistance, Updated Firmware, External Solid State Drive, SDSSDE61-2T00-G25
  • Get NVMe solid state performance with up to 1050MB/s read and 1000MB/s write speeds in a portable, high-capacity drive(1) (Based on internal testing; performance may be lower depending on host device & other factors. 1MB=1,000,000 bytes.)
  • Up to 3-meter drop protection and IP65 water and dust resistance mean this tough drive can take a beating(3) (Previously rated for 2-meter drop protection and IP55 rating. Now qualified for the higher, stated specs.)
  • Use the handy carabiner loop to secure it to your belt loop or backpack for extra peace of mind.
  • Help keep private content private with the included password protection featuring 256‐bit AES hardware encryption.(3)
  • Easily manage files and automatically free up space with the SanDisk Memory Zone app.(5). Non-Operating Temperature -20°C to 85°C

Windows Command Prompt

del /f /a "C:pathtofile.ext"

For a folder and everything inside it:

rmdir /s /q "C:pathtofolder"

/f forces deletion of read-only files, while /a includes files with attributes such as Hidden or System when the path is correct. /s removes the directory tree and /q suppresses confirmation. Microsoft warns that /q removes the entire tree without asking; see the official rmdir documentation.

Windows PowerShell

Remove-Item -LiteralPath "C:pathtofile.ext" -Force

For a folder:

Remove-Item -LiteralPath "C:pathtofolder" -Recurse -Force

-Force permits removal of hidden and read-only items; -Recurse is needed for a directory containing files and subfolders. PowerShell’s item-management documentation explains the cmdlet’s behavior.

macOS and Linux Terminal

rm -f -- "/path/to/file"

For a directory and its contents:

rm -rf -- "/path/to/folder"

Do not run rm -rf until you have inspected the complete path. The -f option suppresses certain prompts and errors, -r removes directories recursively, and -- prevents a filename beginning with a hyphen from being treated as an option. GNU documents these options and warns that ordinary deletion is not secure erasure in its rm manual.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Try the safe fixes first

  1. Close the application that may have opened the file.
  2. Close preview panes, media players, archive tools, editors, terminals, and synchronization clients.
  3. Pause OneDrive, iCloud Drive, Dropbox, Google Drive, or another sync service.
  4. Confirm the full path and whether the target is a file or folder.
  5. Back up anything important.
  6. Restart the computer and try the normal delete operation again.

In Windows File Explorer, right-click the item or select it and press Delete. This normally sends it to the Recycle Bin. Use Shift+Delete only when you intentionally want to bypass the Bin. Emptying the Recycle Bin is a separate operation. On Mac, select the item in Finder and press Command-Delete, then empty the Bin. Apple’s deletion guidance covers protected items and administrator authentication.

How to get and verify the exact path

Windows

In File Explorer, right-click the item and choose Copy as path. Paste the result into Command Prompt or PowerShell. Check that the path points to the intended item and remove any punctuation accidentally copied from surrounding text.

In Command Prompt, inspect hidden and system items with:

dir /a "C:pathtofolder"

In PowerShell, verify a single object before deleting it:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sandisk 1TB Portable SSD, Up to 800MB/s Read Speeds, Black (Old Model)
  • Solid state performance with up to 800MB/s read speeds in a portable drive. (Based on internal testing; performance may be lower depending on host device, interface, usage conditions and other factors. 1MB=1,000,000 bytes.)
  • Back up your content and memories on a storage solution that fits seamlessly into your mobile lifestyle.
  • Take it with you on your adventures—up to two-meter drop protection means this durable drive can take a beating. (Based on internal testing.)
  • Secure it to your belt loop or backpack for extra peace of mind thanks to the tough rubber hook.
  • From Sandisk, a brand professional photographers trust to take on assignments.
Get-Item -LiteralPath "C:pathtofile.ext"

Inspect a directory, including hidden items, with:

Get-ChildItem -LiteralPath "C:pathtofolder" -Force

-LiteralPath is safer than -Path when the name contains wildcard characters such as [ or *.

macOS and Linux

Dragging a file into Terminal can insert its escaped path. Still read the command carefully before pressing Enter. For a directory, inspect its contents first:

ls -la -- "/path/to/folder"

Windows: Command Prompt methods

Delete one read-only or hidden file

Open Command Prompt by searching for Command Prompt. Choose Run as administrator only when the target requires elevation, then approve the User Account Control prompt.

del /f /a "C:UsersNameDownloadsexample.zip"

If Windows says the file cannot be found, list the directory with dir /a and check for a mistyped path, unusual characters, or a stale Explorer view.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Clear file attributes first

attrib -h -s -r "C:pathtofile.ext"
del /f "C:pathtofile.ext"

-h clears Hidden, -s clears System, and -r clears Read-only. This does not change ownership and does not defeat an application lock.

Remove a nonempty folder

rmdir /s /q "C:UsersNameDownloadsOldFolder"

This removes the named folder and every file and subfolder below it, including items that Explorer may not display. Never substitute a parent directory, drive root, or unverified wildcard.

Windows: PowerShell methods

PowerShell is useful when you need literal path handling and a command that can be checked before execution.

Rank #3
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
Remove-Item -LiteralPath "C:pathtofile.ext" -Force

For a directory tree:

Remove-Item -LiteralPath "C:pathtofolder" -Recurse -Force

-Force does not mean “ignore every error.” Permission failures, open handles, read-only volumes, protected system objects, and damaged storage can still stop the operation. PowerShell may also request confirmation in some destructive situations.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Windows permission, ownership, and path problems

Messages such as “Access is denied,” “You need permission,” and “You require permission from TrustedInstaller” do not all have the same cause. The problem may be an NTFS permission, a different owner, a protected system file, a network-share permission, or a process holding the file open. Microsoft discusses these cases separately in its NTFS deletion troubleshooting guide.

If the item is your own data, inspect its Security settings or use an elevated shell. If ownership must be repaired, use these commands only for a precisely identified user file:

takeown /f "C:pathtofile.ext"
icacls "C:pathtofile.ext" /grant "%USERNAME%":F
del /f "C:pathtofile.ext"

takeown changes ownership and icacls grants full control. Applying them broadly can weaken security and is inappropriate for arbitrary Windows system files. Create a backup or restore point first when modifying permissions.

Long or malformed paths

Extraction tools and scripts can create paths with excessive length, trailing spaces or periods, reserved device names, or characters that Explorer handles poorly. An extended Windows path may help in some cases:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
del /f "\?C:verylongpathfile.ext"

This is an advanced technique and does not fix every malformed path, filesystem problem, or network-share limitation.

When a file is in use

/f, -Force, and -f are not universal lock removers. If Windows reports that another process is using the file:

Rank #4
Sale
Sandisk 1TB Extreme Portable SSD, Up to 2000MB/s Transfer Speeds-New Model
  • NEARLY 2X FASTER THAN OUR PREVIOUS GENERATION(8) – move 1,000 high-res photos in under 60 seconds(6) with up to 2000MB/s transfer speeds(2).
  • IP65 RATING AND UP TO 3M DROP PROTECTION(3) – protects against spills and drops.
  • POCKET-SIZED – fits easily in pockets and small bags.
  • SPACE TO OWN YOUR AI CONTENT – speed and capacity to download your high-res clips and photo edits.
  • 256-BIT AES ENCRYPTION(4) – helps keep private files secure with password protection.
  1. Close the application that opened it.
  2. Close preview panes, players, editors, archive utilities, and terminals.
  3. Pause antivirus scanning or cloud synchronization if appropriate.
  4. Restart Windows and retry.
  5. If the lock remains, use Safe Mode or the Windows Recovery Environment.
  6. Use an administrative diagnostic tool to identify the process holding the file.

Do not terminate random processes. Ending the wrong service can cause data loss or system instability. Microsoft’s NTFS guidance identifies open handles as distinct from permissions and attributes.

macOS: Finder and Terminal

Use Finder first: select the item, press Command-Delete, and empty the Bin. If Finder fails, close the application using the item, restart the Mac, and check Get Info for permissions.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

After verifying the full path, remove one file with:

rm -f -- "/Users/name/path/to/file"

Remove a directory tree only when you have inspected it:

rm -rf -- "/Users/name/path/to/folder"

If the item belongs to another user or requires administrator privileges:

sudo rm -f -- "/path/to/file"

Use sudo sparingly. Do not disable System Integrity Protection to remove an ordinary file. If the item is part of macOS, leave it in place unless an Apple-supported uninstall or recovery procedure specifically requires otherwise.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Linux: Terminal methods

For one file:

rm -f -- "/path/to/file"

For a directory tree:

rm -rf -- "/path/to/folder"

A filename beginning with a hyphen must be separated from options:

Best Value
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
  • Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
rm -f -- "-strange-name"

For a permission failure, use administrator privileges only after verifying the path and ownership:

sudo rm -f -- "/path/to/file"

Deletion is generally controlled by permissions on the containing directory, so changing the file’s mode with chmod may not solve the problem. A filesystem attribute can also prevent deletion. Inspect it with:

lsattr "/path/to/file"

If the immutable attribute is present, an administrator may need to clear it:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo chattr -i "/path/to/file"
sudo rm -f -- "/path/to/file"

This is filesystem-specific and potentially dangerous. Do not clear attributes without understanding why they were set.

Cloud-synced files and Recycle Bin or Trash items

A local delete may not be the final action when the item is managed by OneDrive, iCloud Drive, Dropbox, Google Drive, or another synchronization service. The service may:

  • propagate the deletion to other devices;
  • recreate the item from another device or a server copy;
  • show an online-only placeholder rather than a complete local file;
  • retain the item in its own deleted-items area; or
  • apply organizational retention or legal-hold policies.

Pause or inspect synchronization before deleting important data, and check the service’s web interface if the item returns. A file already in the Windows Recycle Bin or Mac Bin may need to be removed from that location rather than from its original folder.

What to do when force deletion still fails

Message or symptom Likely cause Next step
Access denied ACL, ownership, protected file, network permission, or read-only volume Verify the path, inspect permissions, use an elevated shell for user data, and avoid taking ownership of system files.
File is in use Application, service, antivirus, indexer, or sync client holds it open Close likely programs, pause sync, restart, then identify the owning process or use Safe Mode.
Directory is not empty Hidden or system items remain Inspect with dir /a, Get-ChildItem -Force, or ls -la, then use a verified recursive command.
File not found Mistyped path, unusual characters, rename, cloud placeholder, or wildcard interpretation Copy the path again and verify it with an exact-path listing command.
File keeps returning Sync client, backup, deployment script, scheduled task, service, or malware Find the process recreating it instead of repeatedly deleting the symptom.
Drive reports errors Filesystem corruption or failing hardware Back up or image important data, check drive health, and consider replacing the device.

If the drive is failing or mounted read-only, repeated deletion attempts are not a repair strategy. Secure important data before troubleshooting further.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Force deletion is not secure erasure

These terms describe different outcomes:

  • Force deletion: removes an item despite read-only state, hidden attributes, or certain prompts.
  • Permanent deletion: bypasses the Recycle Bin or Trash.
  • Secure erasure: attempts to make recovery substantially more difficult.
  • Device sanitization: erases an entire storage device using an appropriate storage-vendor or organizational procedure.

Normal deletion usually removes a directory entry or deallocates space; it does not guarantee that old contents cannot be recovered. GNU documents this limitation and describes shred as a different tool for a different objective. On Windows, Microsoft’s Sysinternals SDelete is intended for secure deletion, not for solving an ordinary read-only attribute, application lock, or malformed path.

Secure erasure also has limitations on SSDs, journaled filesystems, snapshots, backups, and cloud storage. Removing the local copy does not remove every other copy.

Bottom line

Use the narrowest command that matches the problem: del /f /a for one Windows file, rmdir /s /q for a verified Windows folder, Remove-Item -LiteralPath ... -Force in PowerShell, or rm -f -- on macOS and Linux. Treat recursive deletion and administrator privileges as last-resort tools, verify the path twice, and investigate locks, synchronization, permissions, and failing storage when force flags do not work.

Quick Recap

Bestseller No. 2
Sandisk 1TB Portable SSD, Up to 800MB/s Read Speeds, Black (Old Model)
Sandisk 1TB Portable SSD, Up to 800MB/s Read Speeds, Black (Old Model)
From Sandisk, a brand professional photographers trust to take on assignments.
$165.70
SaleBestseller No. 3
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$129.99
SaleBestseller No. 4
Sandisk 1TB Extreme Portable SSD, Up to 2000MB/s Transfer Speeds-New Model
Sandisk 1TB Extreme Portable SSD, Up to 2000MB/s Transfer Speeds-New Model
IP65 RATING AND UP TO 3M DROP PROTECTION(3) – protects against spills and drops.; POCKET-SIZED – fits easily in pockets and small bags.
$251.93
Bestseller No. 5
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$180.19

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.