By Stephanie / Last update May 11, 2022

Is it possible to recover files from an external hard disk using CMD?

How do I recover files from a formatted external hard disk? I was using the CMD method for the formatting and it takes quite a long about half a day. I'm afraid it was 'zero-filling' my hard disk.”

The command prompt, often known as CMD, lets Windows computer users take control of your operating system by inputting commands. It’s a useful and free tool to fix Windows issues, like hard drive recovery, external hard disk recovery, corrupted hard disk recovery, etc.

You could use the command prompt to fix external hard disks. Besides, if the files in external hard disks are hidden due to some reason, you could use command prompts to recover files from external hard drives.

How to repair external hard disks using CMD?

To repair external hard disks by command lines, you need to run CHKDSK, which means Check Disk. It’s an official Windows tool designed to check the integrity of a hard drive and fix the hard disk when it’s damaged or corrupted. CHKDSK is run in the CMD app and can be used to repair both internal and external hard disks.

Follow the steps below to learn how to use CHKDSK in Command Prompt to repair a damaged external hard disk in Windows 10.

Step 1. Press the “win + Q” keys on your keyboard to open the search box. Type “cmd”. Select “Run as administrator”.


Step 2. Input the following command to check if there are logical errors on your external hard drive.

chkdsk G: (replace H with the drive letter of your external hard drive)

Step 3. If there are some logical errors or bad sectors on your external hard drive, input the commands in turn and press Enter.

chkdsk G: /f (“/f" is a CHKDSK parameter that will check and try to fix logical errors on the hard disk)

chkdsk G: /f /x /r ("/r" will search for bad sectors and restore any usable data. "/x" will unmount the hard disk before scanning to ensure that the procedure is not interrupted by any external factor.)


Step 4. Wait for the command to execute completely.

Recover hidden files from external hard disks using CMD

When your computer is infected with viruses and your antivirus software fails to identify them, you may find the files on your hard disks are lost. When you insert an external hard disk, all of the data on the device is hidden, and there are shortcuts to those files.

In this case, the files are not deleted. They are hidden by some type of virus. If you format the drive, all of the data will be erased. Follow the steps below to recover hidden files and folders from external hard disks without losing the data.

Step 1. Run CMD as administrator.

Step 2. Input the drive letter of the external hard disk. For example G:, and press Enter.

Step 3. Then, type attrib -s -h -r /s /d *.* and press Enter. And then you will have access to all of the hidden files and folders in the external hard disk.


How to recover data from external hard disks for free?

If you deleted files accidentally from external hard disks, you could use the command prompt to recover data. Microsoft released a free command prompt utility from Microsoft Store. It’s called Windows File Recovery. With the command-line window, users only can input command lines to recover deleted or lost files from local storage devices.

Unfortunately, Windows File Recovery currently is only available for Windows 10 2004 and above. There are four different modes to use: Regular, Extensive, Segment, and Signature. You could choose the mode according to the file system of the hard disk and the scenarios of data loss. Here is the command format of Windows File Recovery.

winfr source-drive: destination-drive: [/mode] [/switches]

Step 1. Get Windows File Recovery from Microsoft Store. Type “Windows File Recovery” in the search bar and select “Run as administrator”.

*View solutions to fix “WinFR requires admin privileges to run”.

Step 2. Right-click the external hard disk and select “Properties” to check the file system.

File system


Recommended mode


Deleted recently



Deleted a while ago



After formatting a disk



A corrupted disk


FAT and exFAT



Step 3. Here are some common switches to use. See the description and supported mode of each parameter or switch. Some examples will be listed to make you understand the command format clearly.

*View solutions to fix “Winfr.exe is not recognized as an internal or external command”.


1. If you want to recover an entire folder from E: drive to D: drive, you could input the command like the following:

winfr E: D: /n \Users\Stephanie\Documents\Test\

2. If you want to recover files with the string of “Test”, you could input:

winfr E: D: /r /n *Test*

Parameter / switch  


Supported mode(s)


Scans for a specific file by using a file name, file path, file type, or wildcards. For example: 

  • File name: /n myfile.docx
  • File path: /n /users//Documents/
  • Wildcard: /n myfile.*
  • /n *.docx
  • /n **


Recover specific extension groups, comma separated



Saves a log file of the recovery operation in a different location than the default location on the recovery drive (for example, D:\logfile).



Segment mode, recovery option for NTFS drives using file record segments



Signature mode, recovery option for all file system types using file headers


Windows File Recovery GUI-WinfrGUI

It’s not easy to use with command prompts for everyone, because there is no graphical user interface of Windows File Recovery. For using Windows File Recovery easily and correctly, you could try a  free and useful tool-WinfrGUI, which has invoked the function of Windows File Recovery but with a friendly user interface.

You could use the same function of WinFR with clickable icons. It’s recommended to each one who is not familiar with command lines or faces kinds of errors when using Windows File Recovery. Like Windows File Recovery, WinfrGUI now is only available for Windows 10 2004 and above.

Step 1. Download and install WinfrGUI on your computer.

Download Freeware Win 10 2004 and above
Secure Download

Step 2. Select the external hard drive to scan and set a path to save the recovered files.


Step 3. Choose a scanning method according to the file system of the external hard drive. Quick Scan is only for the NTFS file system. Click “Advanced Settings” if you want to target the file types and folders to scan.


Step 4. Click “Start Recovery” to start the recovery process. Check the destination folder to view the recovered files.


The easiest way to recover data from external hard disk

When you delete some files from an external hard drive, the first thing you need to do is to check the Recycle Bin. But the problem is when most people realize they need to recover data, the files have been deleted permanently from the Recycle Bin. Or some users press the Shift + Delete keys to delete files. In these situations, to recover data from an external hard disk for free, you need a reliable data recovery tool.

AOMEI Data Recovery for Windows is that one! It's an excellent external hard drive recovery software because it can restore hundreds of file types within a few clicks, even for those computer beginners. AOMEI Data Recovery for Windows has a high success recovery rate and fast scanning speed.

AOMEI Data Recovery for Windows

▶ Recover deleted files from SD cards, USB flash drives, HDDs, SSDs, external hard drives, and other storage media.
▶ Support for permanently deleted files recovery, formatted file recovery, and other data recovery methods.
▶ Recover lost Word, Excel, PowerPoint photos, videos, audios, emails, and hundreds of other file types.
▶ Compatible with Windows 7/8/10/11 and Windows Server.

Download SoftwareWin 11/10/8/7/Server
10,000 people have downloaded it

Step 1. Download and launch AOMEI Data Recovery for Windows on your computer. Select your external hard disk to scan.


Step 2. The software runs the scanning process from quick scan to deep scan and finds deleted files and other missing files in the external hard disk.


Step 3. During scanning, you could recover any file you want. Select the file or the folder that you want to recover and click "Recover files".


To sum up

Command Prompt offers numerous advantages to help users recover hidden files from an external hard drive. Besides, it’s useful to use CMD to repair external hard disks when there are logical errors or bad sectors.

Windows File Recovery, as a command-line app, makes external hard disk data recovery possible, but it's highly recommended to use AOMEI Data Recovery for Windows to restore data from external hard disks with a higher success rate. 

Unfortunately, the best data recovery tool couldn’t recover all lost or deleted data on hard disks. Making a regular backup is always the most effective way to avoid data loss. You could try freeware-AOMEI Backupper to make system backup, partition backup, file backup, etc to keep your data safe.