“The Directory Name is Invalid” Error and How To Fix It

6488

the directory name is invalid

Tried to open a folder, only to be met with the error message “The directory name is invalid.”? This error will persist, preventing you from accessing the data. This usually happens due to incorrect permissions, but sometimes it can be bad sectors. Thankfully, there are several ways to fix this message. We’ve included some tried-and-true ways of fixing the directory is invalid error and getting back to your data.

Common Causes of “The Directory Name Is Invalid” Error

The directory name is invalid error occurs when, for some reason, Windows unsuccessfully attempts to access a directory. It could be triggered by you manually, or by Windows trying to run a program in the background. It can also happen when your USB flash drive isn’t recognized and Windows tries to access it. Listed below are some common reasons why this can happen to you.

Cause Description
📥 Improper device removal Removing your device without safely ejecting it first can interrupt delicate write processes, resulting in incomplete transfers that can corrupt your data or file system.
🗯 Malware attack A virus could have infected your drive, potentially corrupting your file system and preventing Windows from accessing certain parts of your drive.
📂 Incorrect permissions If you do not have the correct permissions to access the folder or device, Windows may return this error message as an indicator.
💿 Bad sectors on the drive Windows is unable to detect bad sectors by default, so it’s possible that it’s trying to access a location that is no longer accessible.
⛓️‍💥 Loose or faulty connection A loose or faulty connection typically stems from the connection points and usually affects portable media like USB flash drives, SD cards, CD/DVD drives, and external hard disk drives (HDDs) and solid-state drives (SSDs).
💥 Faulty or unpowered USB port The USB port you’re using may have a physical issue preventing it from reading the device. Likewise, it may be disabled through the settings of your operating system (OS).
🔠 Invalid or missing driver letter Windows requires connected storage devices to have a drive letter before you can view the data. It’s possible for your drive letter to vanish following a Windows update, but reassigning or adding a new one should fix it.
🔧 Application/software-specific issues This message can appear in applications. For example, Microsoft Visual Studio will do this if you’re trying to run the wrong version of SQL Server.

We’re going to guide you through recovering data in the event the drive is failing, facing serious corruption, or experiencing any event where data loss is possible. If the data on the drive is valuable to you, you must recover it before attempting any fixes. Some fixes, such as CHKDSK, have been known for fixing the issue at the expense of your data. Therefore, we always recommend that you recover the data first and foremost.

How to Recover Files When the Directory Name Is Invalid

If your drive says the directory name is invalid on your Windows 10 or 11 computer, recovering the data is still possible as long as the drive is recognized by the Device Manager and reads the correct size. Instead of using File Explorer to get your data, we’ll be using data recovery software.

Disk Drill is our preferred data recovery tool for recovering files where access is blocked by Windows error messages. It can bypass the error message and scan the drive directly, using several scanning methods to uncover data even if it’s been lost to file system corruption.

Follow these steps to recover any files on a drive that says the directory name is not valid:

  1. Download and install Disk Drill. Avoid installing Disk Drill on the same drive that you’re recovering data from.
  2. Select the drive that’s causing the error message. Click Search for lost data. The scan will begin.Scanning the problematic drive,
  3. Choose a scan type if you’re scanning a disk image, portable device, or internal non-system drive. The Universal Scan will look for as many files as possible, while Advanced Camera Recovery is ideal for recovering unedited videos from cameras and drones.Starting the Universal Scan.
  4. Click Review found items to look at what Disk Drill has found. You can do this during the scan or after it has been completed.Reviewing the data Disk Drill found,
  5. Preview and select the files you want to recover. The results are broken down into three categories: Existing, for existing files, Deleted or lost, for deleted files, and Reconstructed, for files that were reconstructed by their unique file signature. When ready, click Recover.Recovering the selected files.
  6. Choose an output location that resides on a separate physical partition to avoid corrupting your data. Click Next to finalize recovery.Finishing Disk Drill recovery.

Disk Drill lets you recover up to 100 MB of data for free before upgrading. It also gives you unlimited access to its byte-to-byte backup and S.M.A.R.T. monitoring features.

How to Fix “The Directory Name Is Invalid” Issue

Once you’re finished with file recovery, you can safely move on to diagnosing and fixing your drive so the error message no longer appears. Work through each method to ensure you don’t miss any important troubleshooting steps.

Method 1: Try Another Port

If Windows says the directory name is invalid when your USB drive, SD card, or external hard drive is connected, it may be caused by the USB port you’re connecting to. If the USB port is faulty, it can act erratically when devices are connected and break down communication between the device and your operating system.

Try connecting to another USB port. If successful, you can diagnose the original USB port to resolve the issue. If the USB drive directory name is still invalid, move to the next method.

Method 2: Double-Check the File Path and Name

As simple as a mistake might be, more often than not, this error message can show when the directory path is mistyped. Before we look at more advanced fixes, confirm that the path is correct, especially if it’s being typed out manually.

Some quick tips for avoiding common mistakes when dealing with file paths:

  • Use quotation marks if you’re using cd. For example, cd “C:\Program Files\MyFolder”.
  • Windows uses backslashes (\), not forward slashes (/).
  • If you’re unsure, open the folder in File Explorer, click on the navigation bar at the top, and it will give you the full path in its correct format.

The folder path.

Method 3: Fix Using CHKDSK (CheckDisk)

CHKDSK is a utility included with Windows that specializes in finding and resolving issues relating to your drive’s file system. It remains a reliable solution for fixing this particular error message, but there’s also a risk of CHKDSK deleting your data.

In these steps, we’ll be using the /r flag. It’s the better option between CHKDSK /f and /r, as it also checks for physical and logical bad sectors.

Running CHKDSK may fix the issue that’s triggering Windows to say the directory name is invalid when opening a file. Follow these steps to do so.

  1. Right-click the Start button, then select Terminal (Admin).Opening Terminal.
  2. Type chkdsk D: /r. (Replace D: with your own drive letter). Press Enter.Running the CHKDSK command.

Method 4: Check Permissions

If your drive is NTFS-formatted and you do not have the correct permissions to view the file or folder, Windows may reject your attempt by saying the directory name isn’t valid. Permissions are used to secure your data and protect it from other users accessing it, especially on shared computers.

You may need to be logged in to (or know the credentials to) an administrator account to perform this if your own account lacks access.

Follow these steps to check the permissions of a folder and update them if necessary.

  1. Navigate to the parent folder in Windows Explorer. Right-click the folder having issues, then select Properties.Accessing the folder properties.
  2. Go to the Security tab. Click Edit.Editing the user permissions.
  3. Select your user account and make sure you have the correct access. In particular, you want to have read and write access. If the Allow box for either of these is unticked, tick them and click Apply (also make sure that the Deny box is unticked, as it will always take priority).Reviewing the user permissions.

This error can happen in a unique instance where you’re trying to access a Word document in OneDrive. Open Task Manager and restart the Windows File Explorer process to fix the error in this case.

Method 5: Check for Viruses

Viruses can do a multitude of malicious things to your drive. This includes the ability to delete directories or tamper with them in a way that prevents Windows from reading them. Thankfully, recovering deleted files is possible. But, if your computer has been infected by a virus, you may need to remove it first to resolve the Windows message that states the directory name is not valid.

You can scan your computer with any antivirus software, but these steps will guide you through performing a scan using Windows Security.

  1. Press Windows Key + S on your keyboard and search for Windows Security. Open the first result.Open Windows Security.
  2. Click Virus & threat protection.Selecting the Virus & Threat protection section.
  3. Click Scan options.Checking the additional scan options.
  4. Select Full scan then click Scan now.Running a full scan using Windows Security.

Method 6: Investigate Scheduled Tasks and Startup Entries

If the error appears at boot or on a regular schedule (without you launching anything), something running in the background may point to a missing or invalid folder/drive. Check Task Scheduler, as well as the applications that are configured to run at startup, and look for any tasks that are set to run around the time when the error message appears.

Here’s how to check the Task Scheduler and startup apps:

  1. Open Start, search “Task Scheduler”, and open it.Opening Task Scheduler.
  2. Click Task Scheduler Library.Checking the Task Scheduler Library.
  3. Look for suspect tasks. If you find one, select it, then click Disable.Disabling a task.
  4. Right-click your taskbar, then click Task Manager.Opening Task Manager.
  5. Click Startup apps.Checking the startup apps.
  6. Disable any apps that have no valid folder location.Disabling a startup app.

Method 7: Boot Into Safe Mode

When you boot into safe mode, Windows only loads the files that are necessary for your computer to function. Anything extra will not be loaded on boot to prevent it from interfering with Windows. This gives you the opportunity to diagnose the problem, like uninstalling suspicious software and running repair utilities.

  1. Press Windows Key + I to open Windows Settings. Click Update & Security.Opening Windows settings.
  2. Click Recovery.Accessing the Windows recovery section.
  3. Under Advanced startup, click Restart now. Your computer will restart.Booting into advanced startup.
  4. Click Troubleshoot.Accessing the troubleshooting options.
  5. Select Advanced options.Checking the advanced options.
  6. Click Startup Settings.Clicking Startup Settings.
  7. Click Restart to boot into safe mode.Restarting the computer.
  8. Press 5 to boot into Windows safe mode with network access. If you don’t want network access, press 4 instead.Choosing how to boot safely.

Once you’re in safe mode, see if the message still appears. If it doesn’t, this means it could be in relation to an application on your computer. Now that you’re aware, you can restart your computer like normal and look through your installed applications to see if there are any that could be causing this.

Final Words

We’ve tested all of the methods in this list and can confirm they do work. However, that’s not to say they will always work. We have come across stubborn cases on external drives and SD cards where formatting was essential. Formatting is basically a factory reset, deleting all data on the device, while also fixing all logical damage.

If worst comes to worst, formatting is an option. However, you should recover the data first, as there’s no guarantee it will be recoverable after formatting. Here’s a brief guide on how to format a drive where the directory name is invalid on Windows 11:

  1. Open File Explorer.
  2. Right-click on the storage device and click Format.
  3. Make sure Quick Format is ticked, then click Start.
  4. Click OK to confirm.

Did we manage to fix your issue? Tell us about your experience in the comments below. Check out the FAQ below for more info, or if you have a question for us, feel free to get in touch directly.

FAQ

If you connect your external hard drive and it says the directory name is invalid, the first thing you should do is try connecting it to another USB port (preferably a back panel one on desktops as it connects directly to the motherboard). If that doesn’t work, you can see if it’s an issue with the file system by checking the drive for errors using the building error checking function (that utilizes CheckDisk) in Windows.
  1. Open Windows File Explorer.
  2. Right-click the drive, then select Properties.
  3. Click Tools.
  4. Under Error checking, click Check.
  5. Click Scan drive.
This means the file has either been renamed, moved, or deleted. The directory name isn't valid in Microsoft Word when it is unable to locate the file you’re trying to open. Try using Windows Explorer to search for the file manually, either by keyword or file extension.
Not necessarily. It just means that Windows was unable to properly access the SD card. In all likelihood, your footage is fine, just inaccessible. The safest way to get that data back is by using data recovery software. After it’s recovered, you can repair the SD card to restore access.
If your external hard drive, SD card, or USB directory name is invalid, it could be a problem with the file system. Use CheckDisk to scan for and fix any file system related issues with the external hard drive by following these steps:
  1. Right-click Start. Select Windows PowerShell (Admin).
  2. Type chkdsk D: /r. (Replace D: with your own drive letter). Press Enter.
A lot of the time, this happens when Windows loses track of removable drives or network paths during sleep. When the system wakes, the drive letter or path isn’t reinitialized properly, so programs or shortcuts referencing this location will present the error message.
If you’re trying to run something in a task scheduler but it returns the error "The directory name is invalid” error 0x8007010b, it’s very likely being caused by the use of quotation marks for the specified location. Removing the quotation marks surrounding the directory path should resolve the issue.
0 COMMENTS
This field is required
This field is required
We respect your privacy; your email address will not be published.

We respect your privacy; your email address will not be published.

You have entered an incorrect email address!
This field is required