Fix The Directory Name is Invalid Error

Fix ‘The Directory Name is Invalid’ Error on Windows 10/11

Last updated:

No robots used, our articles are crafted by humans under strict Editorial Guidelines.

Written by Arjun Ruparelia Arjun Ruparelia Contributing Writer • 15 articles Arjun Ruparelia is a contributing writer for Handy Recovery, specializing in resolving data loss issues on Windows OS and external devices. He joined our project in 2021 and has since developed his own unique approach to formatting articles, which has proven to be engaging and effective. LinkedIn Approved by Andrey Vasilyev Andrey Vasilyev Editor Andrey Vasilyev is an Editorial Advisor for Handy Recovery. Andrey is a software engineer expert with extensive expertise in data recovery, computer forensics, and data litigation. Andrey brings over 12 years of experience in software development, database administration, and hardware repair to the team. LinkedIn

You get “The directory name is invalid” error when opening a file on your PC, USB drive, or SD card because of several reasons like bad sectors on the drive, faulty device drivers, or damaged SATA port.

You might’ve just entered the wrong directory in some cases. For example, when using the Run program in Windows, you could’ve typed the directory name incorrectly, which means the directory name isn’t valid and won’t open.

🗨️

We explain how you can resolve this error and how to recover your files in cases where necessary.

How to Fix “The Directory Name is Invalid” in a Few Easy Steps

Now that you’ve understood what the directory name is invalid error means, let’s discuss a few methods that can help you fix the error and regain access to your folder on Windows, USB drives, or SD cards.

Step 1. Check the Path and File and Folder Name

Sometimes the error is mechanical rather than technical. When you write the path or file or folder name incorrectly, you’ll receive the directory name is invalid on Windows 10 or 11.

For example, say you have a folder containing files created using Microsoft Word and Excel, and both have the same name. When you try to access the path “C:\Office\Documents\filename”, you’ll receive an error since you haven’t mentioned the file extension. Windows won’t know which file to open since multiple files with the same name exist in that folder.

The file extension is important to access the file. Note that Microsoft Word can also export files in other extensions like PDF. Don’t assume a file is a .doc file if it was created using Microsoft Word.

You should also check you’re using the correct naming convention. For example, you might be using a forward slash (C:/) instead of a backward slash (C:). This is incorrect and will result in the directory name is invalid error. The File Explorer and the Run program can automatically fix the forward slash, but it’s a problem when you’re using tools like Command Prompt.

Step 2. Try Different USB Ports

The USB port you’re using for your USB drive, external hard drive, or SD card reader may be damaged or faulty. Just try using a different USB port to see if the error persists. If you’re able to solve the error, seek help from a professional to get your port fixed.

Step 3. Make Data Backup If Possible

If you’re still seeing the directory name is invalid when using/inserting a USB, pendrive, or SD card, it’s best to create a backup. This ensures your data is safe.

If you end up damaging the storage device somehow, you’ll need to put extra time and effort into recovering data from a broken flash drive or failed SD card. In the worst cases, you’ll need to contact a professional data recovery service.

However, if you have a backup, you can use it to recover the data yourself. You can use a recovery tool like Disk Drill (read our Disk Drill review) to do this.

How to Create Byte-to-Byte Backup

Disk Drill, one of the best data recovery apps on the market, allows you to create a backup image of your storage device using its Byte-to-Byte backup feature. Here’s the complete process for creating a backup using Disk Drill:

  1. Download Disk Drill and install it on your PC.installing disk drill
  2. Launch Disk Drill and switch to the Drive Backup section from the left sidebar.selecting byte to byte in Disk Drill
  3. Select a disk you want to backup and click on Byte-to-Byte Backup at the top-right corner.creating byte to byte backup
  4. Enter a path where you want to store the backup and click OK to create the backup.creating a backup path

You can use this image to recover files if needed by attaching the image as a disk in Disk Drill as we explain in step 6.

Step 4. Run CHKDSK in Command Prompt

CHKDSK is a built-in command-line utility in Windows that helps detect and fix disk-related issues like bad sectors and filesystem errors. If these issues are the reason why you’re getting the device name is invalid on Windows 10/11, CHKDSK can help.

The CHKDSK command is generally used with the /r switch. For example, the command might look like this:

chkdsk C: /r

The command checks volume C for bad sectors and attempts to repair them so they’re readable within the file system.

đź‘€

Note: The /r switch includes the /f switch’s function so you don’t need to type the /f switch.

However, instead of using /r, you should use the following command:

chkdsk C: /f /r /x

You need to run the command in CMD. Press Ctrl + R, type cmd, and press Ctrl + Shift + Enter to launch an elevated Command Prompt. Then, copy and paste the command above (but replace the drive letter).

using chkdsk on windows

Executing this command scans the file system and sectors and fixes those errors, all with the same command. More importantly, the command also dismounts the drive first if necessary.

Step 5. Format Your SD Card or USB Drive

If CHKDSK didn’t help, you should consider formatting as your last resort option. However, this option is viable if you’re receiving the directory name is invalid when inserting an SD card or USB pen drive.

If you’re unable to format the SD card or pen drive because of errors, use another device or a different operating system to format the device. While there are a few ways to format an SD card without losing data or format a USB stick without losing data, you can always format and use the backup you created using Disk Drill to recover data.

Step 6. Retrieve Your Data With Recovery Tool

After you’ve formatted your USB flash drive or SD card, you’ll need to recover the data from the formatted SD card or formatted USB drive. You can use Disk Drill to recover data from formatted drives, provided you had performed a quick format. However, the chances of recovery are still the best when you create a byte-to-byte backup (as explained in step 3).

đź‘€

Note: The free version allows recovering up to 500MB of data.

  1. Start by attaching the disk image using the Attach disk image option on the app’s home screen. Click on the option and select the image file to attach.attaching disk on Disk Drill
  2. You’ll now see the image file in the list of disks. Select the disk image from the list and click on the Search for lost data button.scanning disk image using Disk Drill
  3. Once the scan is complete, select the files you want to recover. The backup contains data from the entire disk. However, you might have been trying to access a specific file when you get the directory name is invalid error. The good thing is, Disk Drill helps you filter the list of recoverable files. You can choose to recover all files or filter the list for specific file types you want to recover. For example, you can select Pictures from the left sidebar to only see pictures in the list. Alternatively, you can narrow down the list further based on a file extension. For example, you can type “.png” in the search bar at the top-right to only see png files in the list. You can also preview the images by clicking on the tiny eye icon to determine if that’s the file you want to recover.filtering by file extension
  4. Select the files you want to recover by selecting the box to the left of the filename. Then click the Recover button at the bottom.recovering files
  5. Select a recovery path. This is where Disk Drill will save the recovered files.selecting a recovery location

That’s all you need to do to recover data from an SD card or USB pen drive and regain access to your directories.

FAQ

You can fix the directory name is invalid error by checking that you’re using the correct path and file and folder name or changing the USB port you’ve used for connecting your device. If neither solution works, try formatting your device, but be sure to create a backup before formatting.

The directory name is invalid error appears when you’re using an incorrect path or file or folder name. It can also occur when you’re using a damaged or faulty USB port. In some cases, the error results from filesystem corruption or bad sectors in your storage device.

The error occurs in Microsoft Word when the file has been deleted, renamed, or moved from its original location. However, you can still access the file using the File Explorer. When you find the file, you’ll be able to launch the file like usual with Microsoft Word.

Error 0x8007010b (the directory name is invalid) appears in the taskbar when you use quotation marks for the path entered in the “Start in” field. When creating a basic task in the Task Scheduler for starting a program based on a trigger, you’re asked to select a program/script as well as a “start in” folder.

You have the option to browse using File Explorer and select the program or script, but not for the “start in” folder. Most would just copy the path and remove the file name, and this results in the inclusion of quotation marks. Remove the quotation marks from the path in the “start in” folder (but keep them in the program/script field) and that should solve the problem.

You can generally fix the problem by double-checking the path you’re using. See if the path includes any special characters and that you’ve used the correct file extension.

About article
Contributing Writer Arjun Ruparelia

This article was written by Arjun Ruparelia, a Contributing Writer at Handy Recovery. It was also verified for technical accuracy by Andrey Vasilyev, our editorial advisor.

Curious about our content creation process? Take a look at our Editor Guidelines.

How do you rate the article? Submitted: