sodcalculator

10 Tech How-To

The Directory Is Not Empty Error on Windows: Fixes

Guide 10-40992 · Updated · Step by step

The “The directory is not empty” message in Windows usually appears when you try to delete, move, rename, or replace a folder that still contains files, hidden items, or something another program is using. These steps help you find what is preventing the operation and remove or release it safely. Before deleting anything, confirm the folder’s contents are not needed and that you have permission to change it.

What You’ll Need

  • Access to the affected folder and permission to change or delete it.
  • An administrator account if Windows asks for elevated permission.
  • Optional: a backup of important files before you remove folder contents.

Step-by-Step

  1. Check what operation failed. Note whether the message appeared while deleting, renaming, moving, or replacing a folder. If the folder is on a USB drive, network share, or synced location, also check that the drive or connection is available. Do not assume the folder is empty just because File Explorer shows no visible files.
  2. Open the folder and show hidden items. In File Explorer, select View > Show > Hidden items on Windows 11. On Windows 10, open the View tab and check Hidden items. Look for hidden files and subfolders. If you recognize items that should be kept, move or back them up before trying the operation again.
  3. Check for files that are still being created or used. Close any File Explorer windows displaying the folder, and exit programs that may have opened files there. This can include document editors, media players, installers, backup tools, and command windows whose current location is inside the folder. Wait for any copy, extraction, or sync operation to finish, then retry.
  4. Try the operation again from File Explorer. Select the folder and press F5 to refresh the view. If deleting, select it and press Delete; use Shift+Delete only if you intend to bypass the Recycle Bin and permanently remove it. If moving or renaming, try a short, simple name and a local destination with enough available space. Avoid permanent deletion until you have checked the contents.
  5. Restart Windows, then retry. A restart can release a file handle left open by a program. Save your work and restart from Start > Power > Restart. After signing back in, avoid reopening apps that might use the folder and try the operation once more. A restart is preferable to deleting files blindly.
  6. Use Command Prompt for a confirmed deletion. Only continue if you are certain the folder and everything inside it can be removed. Search Start for Command Prompt, right-click it, and choose Run as administrator if permission is required. To inspect a folder, enter dir /a "C:\path\to\folder", replacing the example path with the actual one. To delete the folder and its contents, use rmdir /s "C:\path\to\folder". Windows asks for confirmation; review the path carefully before entering Y. This command does not send the contents to the Recycle Bin.
  7. Check the path and permissions if the command fails. Make sure the path is correct and enclosed in quotation marks, especially if it contains spaces. If you see “Access is denied,” confirm that you are signed in with an account allowed to change the folder. You can right-click the folder, choose Properties > Security, and review the listed permissions. Do not change ownership or permissions on Windows system folders just to force deletion.
  8. Check the drive if the problem persists. For a local drive, open This PC, right-click the drive, choose Properties > Tools, then select Check under Error checking if available. Follow Windows’ prompts. For a USB or external drive, safely eject and reconnect it, then retry. If it is a network folder, check the connection and ask the folder administrator whether you have the needed access.

Common Mistakes

  • Deleting the wrong folder. A command such as rmdir /s removes the named folder and its contents without using the Recycle Bin. Verify the full path before confirming.
  • Assuming hidden means disposable. Hidden items can be app data or files required by a program. Inspect unfamiliar contents rather than removing them automatically.
  • Using wildcards or shortened paths carelessly. Commands that target a broader path than intended can remove more than one folder. Enter the full path and use quotes around it.
  • Changing permissions as a first step. Taking ownership or granting broad permissions can create security and system problems. First check that you are using the right account and that the folder is not managed by Windows or another organization.
  • Retrying during a copy or sync. Interrupting an active transfer may leave incomplete files behind. Let it finish, or cancel it through the application that started it.

Tips

  • Copy important files somewhere safe before clearing a folder, especially if you do not recognize its purpose.
  • When working with commands, copy the folder path from File Explorer’s address bar and check it character by character before running a destructive command.
  • If you are deleting a temporary folder, close the program that created it first. Use that program’s own cleanup or uninstall option when available.
  • For a shared or work-managed folder, contact its owner or administrator rather than bypassing permissions.

Troubleshooting

The folder looks empty, but Windows still reports that it is not. Turn on Hidden items and inspect nested subfolders. Also check whether the folder contains a file with an unusual name or whether an application is still writing to it. Restart and retry if you cannot identify an open program.

“Access is denied” appears. The account may lack permission, the folder may be protected, or a file may be in use. Try closing apps and restarting. If the folder belongs to another user, a workplace, or Windows itself, ask the owner or administrator for help rather than forcing access.

Command Prompt says the path cannot be found. Check for a typo, missing drive letter, or an incorrect folder name. Keep quotation marks around paths containing spaces. You can type dir /a "C:\path\to\parent" to list the parent folder and confirm the exact name before trying again.

The error returns after the folder is deleted. A program, sync service, or installer may be recreating it. Identify which app uses the folder and stop or configure that app before removing the folder again. If the folder is on a drive that reports errors, back up important data and use Windows’ drive-checking option.

The folder is on a network or external drive. Confirm the device is connected and accessible, then retry. Network permissions may be controlled by an administrator. If the drive disconnects, reports errors, or contains important data, avoid repeated forced deletion and back up what you can first.

Frequently Asked Questions

What does “The directory is not empty” mean?
Windows found one or more items in the folder, or the folder could not be changed as requested. Hidden contents, nested folders, or files in use are common reasons.

Can I delete the folder from Command Prompt?
Yes, but rmdir /s "full\path\to\folder" permanently removes the folder and its contents. Confirm the path and back up anything important before proceeding.

Why does File Explorer show an empty folder?
Hidden items may not be displayed, or the contents may be nested or temporarily in use. Enable Hidden items, refresh the view, and restart Windows if needed.

Will restarting fix the error?
It can, if an app or background process has a file open. Save your work, restart, and try again before using a permanent-delete command.

Should I change folder ownership to delete it?
Usually not as a first fix. Check permissions and ask the folder’s owner or administrator. Avoid taking ownership of Windows system folders.

What if the folder is on a USB drive?
Reconnect the drive, check that it is accessible, and use Windows’ drive error-checking option if the issue continues. Back up important files before attempting destructive repairs.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →