Recover Data from External Hard Drive Using CMD: 2024 Guide

Have no idea how to recover files from external hard drive using Command Prompt? Dive into this comprehensive tutorial for a step-by-step guide that enables you to restore your deleted or lost data with ease.


By Phoebe / Updated on March 22, 2024

Share this: instagram reddit

Can I recover deleted files from external hard drive using CMD?



"Hello! When I plugged my 1TB SanDisk SSD into my computer and found data on my external hard drive had gone. I have been using my disk for three years, and there are so many important photos and files stored on it. I cannot lose them. Is it possible to recover my data using CMD? I am a little reluctant to download additional data recovery software."

Source: SanDisk Forum


This user discovered that data stored on his or her hard disk disappeared and didn't know how to recover files from external hard drive using Command Prompt. Is it possible to recover files from external hard drive using CMD without data loss?

Yes, it is possible. CMD, short for Command Prompt, is a powerful built-in utility in Windows designed to troubleshoot and resolve specific issues with internal and external storage devices.

If you intend to recover deleted files from an external hard drive using CMD, it's crucial to understand a prerequisite: Command Prompt is effective for recovering data lost due to factors like accidental deletion, virus attacks, and corruption, but it may not resolve data loss caused by logical errors. For scenarios involving logical mistakes, professional data recovery software or services are recommended for successful data retrieval.

How to maximize the likelihood of successful data recovery

External hard drives have been widely used for expanding storage capacity, transferring files between different devices, creating backups, and transporting data. The longer you use it, the more data you store on it, and the more vulnerable the data becomes.

However, information is incredibly delicate and not entirely secure, regardless of where or how it is stored. The only sure way to retrieve lost data is to maintain a backup in advance. If there is no backup, you may still remember three tips to improve the chances of data recovery and avoid further damage once a data loss incident occurs.

▲ Stop executing "write" functions. A widespread belief says that once data gets deleted, it is actually not erased but exists in another file name. Hence once you conduct "write" operations such as editing, creating, and coping, the intact data will be overwritten and make it impossible to perform recovery.
▲ Don't reboot the drive. Rebooting causes the computer to write new files. So you are suggested to turn off the computer and not turn it on.
▲ Never format the external hard drive. Format would be the last resort. Once you format a disk, many hard drive issues can be solved, but all the data stored on it will be totally erased. Before formatting a disk, please try other recovery methods.

How to recover files from external hard drive using Command Prompt

As mentioned earlier, the probability of successful recovery using CMD depends on the specific circumstances of data loss. The following parts will delve into how to recover permanently deleted files using CMD.

Warning: Please follow the command line carefully. Wrong typing errors can cause severe consequences.

Recover files from external hard drive using attrib

How to recover files from external hard drive using Command Prompt? The first option is to use Command "attrib" which is designed to delete and set or display file attributes like read-only, hidden, system, and archive.

This command is applicable to: accidental deletion, hiding, and virus attacks data recovery.

Step 1: Connect the external hard drive to your computer.

Step 2: Press Win + R to open the Run window.

Step 3: Type "CMD," and press Ctrl + Shift + Enter to run Command Prompt as Administrator.

Step 4: Type "attrib -h -r -s /s /d F:\*.*" and hit Enter.

(Replace "F" with the exact letter of your external hard drive.)


Recover files from external hard drive using chkdsk

Command "chkdsk" is used to check a hard drive or other disk drives for errors and repair them if possible.

This command is applicable to: RAW or corrupted file system recovery.

Step 1: Run Command Prompt as Administrator.

Step 2: Type "chkdsk g: /f /r  /x" and hit Enter.

(Replace "g" with the exact letter of your external hard drive.)


Now check the drive to see if the lost files have been recovered. If these CMD methods do not fully recover your files, consider using a trusted third-party data recovery tool.

How to recover files from external hard drive using the best CMD alternative

While CMD is a powerful built-in utility, it has limitations in handling more complex data loss scenarios. For situations like emptied recycle bins, formatted disks, lost partitions, and system crashes, CMD may not be sufficient. Additionally, it's advisable to avoid using CMD unless you're confident in your commands' accuracy. A mistyped command can potentially exacerbate existing issues or create new problems.

In such cases, a dedicated data recovery program is necessary. We recommend using user-friendly options like AOMEI Partition Assistant Professional. The following points make AOMEI software stand out from all file recovery tools:

✿ Recover files from permanently deleted, corrupted, formatted, and more data loss scenarios.
✿ Restore Word, Excel, PowerPoint photos, videos, audio, emails, and more than 200 file types.
✿ Retrieve deleted files from external hard drives, USB flash drives, SD cards, HDDs, SSDs, and other storage media.
✿ Provide versatile partitioning, cloning, converting, and more advanced features.

Free DownloadWin 11/10/8.1/8/7/XP
Secure Download

After making sure you have connected the external hard drive to your computer, follow the next instructions carefully.

Step 1: Install and launch AOMEI Partition Assistant on your computer.

Step 2: Click on "Recover" and then choose "Recover Data".


Step 3: Select the external hard drive where the deleted or lost files were stored and click "Start Scan".


Step 4: After the scan is complete, preview the recovered files, and select the ones you want to restore. Click "Recover".


Step 5. Select a folder path to store the recovered items and click "Select Folder".


Step 6. When you see the small window below, click "OK".


Then the recovered files will be saved in the specified location.

Bonus: How to fix a corrupted and unreadable external hard drive

"I:\ drive is not accessible. The file or directory is corrupted and unreadable." is one of the most common partition corrupted errors that happen to the external hard drives. This can be caused by many situations: physical damage or failure, virus or malware infection, bad sectors or file system errors, and so on.

The good news is that fixing the issue can be easy. There are 4 tips you can use:

1. Check physical connections: ensure that the external hard drive is properly connected to your computer. Try using a different USB port or cable to rule out connection issues.

2. Use a different computer: try connecting the external hard drive to a different computer to see if the issue persists. this helps determine if the problem is with the drive or the computer.

3. Run CHKDSK: on Windows, open Command Prompt as an administrator, and run chkdsk /f X: (replace X with the drive letter of your external hard drive). Check for drive errors and repair them.

4. Use disk repair tool: If the drive remains unreadable, employ AOMEI Partition Assistant to diagnose and repair issues, including checking for bad sectors and resolving logical errors. Additionally, considering reputable data recovery services is advisable for reliable solutions.


This article mainly talks about how to recover files from external hard drive using Command Prompt. Two command lines - "attrib" and "chkdsk" are introduced in detail.

While CMD can be effective for certain data recovery scenarios, its capabilities are limited. For more complex data loss situations, especially those involving logical issues, using a dedicated data recovery tool like AOMEI Partition Assistant is highly recommended. Besides the PC edition, this tool also encompasses the Server edition for Windows Server users and other advanced editions for enterprise users.

Phoebe · Staff Editor
Phoebe, an editor at AOMEI Technology, is dedicated to offering optimal solutions for Windows-related concerns, specializing in partition management, disk upgrades, data recovery, and more. During her free time, she enjoys indulging in reading, watching movies, and exploring her passion for cooking.