By Stephanie / Last update May 12, 2022

Can I recover lost files from hard disks using the command prompt?

Nowadays, data security is particularly important to everyone. Because data is stored in kinds of storage devices, such as computers, smartphones, SD cards, USB flash drives, etc. It’s frustrating if you accidentally deleted or lost vital data from your hard drive.

Data loss could happen for kinds of reasons, like accidental deletion, hard disk corruption, virus attack, etc. Whatever the causes leading to hard drive data loss, finding the data back is the most important.

Users may wonder is it possible to recover files from hard drives using CMD. The answer is yes.

Microsoft released an official command-line app (Windows File Recovery) to recover deleted/lost files in Windows 10 and above. If your Windows operating systems are Windows 10 2004 below, you could use the “attrib” command to make hidden files visible again.

Recover hidden files from hard drive using CMD in Windows 10/8/7

The Windows built-in utility, Command Prompt, is used to control your computer using various commands. It may also fix some Windows-related issues. It is a free alternative method of third-party Windows data recovery software.

CMD can be used to recover hidden files from a computer hard disk, USB flash drive, pen drive, memory card, or other external hard drives. Hidden files are usually caused by a virus or simply because you do not have permission to view all hidden files. Follow the steps below to learn how to recover hidden files from hard drives using CMD.

Step 1. Press Windows + X keys, select “Command Prompt (Admin)” or “Windows Powershell (Admin)” for Windows 10.

Step 2. Type attrib -h -r -s /s /d E:\*.* and hit Enter. (Replace E with the drive letter in which you lost files)


Step 3. Wait for the command to finish.

Attrib syntax meaning:

–h Used to clear the Hidden file attribute.

–r Used to clear the Read-only file attribute

–s Used to clear the System file attribute.

/s applies command lines to matching files in the current directory and all of its subdirectories.

/d applies command lines to directories.

Recover files from hard drive via Windows File Recovery

Windows File Recovery is a command-line application that can be used to recover files that have been deleted from your computer. In 2020, Microsoft released the file recovery tool, which you can use to try to restore data on your hard disk, external storage, and USB flash drives. It doesn’t support cloud storage and network files. It is currently available to Windows 10 2004 and above.

Windows File Recovery is free to use. However, it is important to understand that the Windows File Recovery tool is a command-line utility. It lacks a graphical user interface (GUI) with clickable buttons.

To retrieve your data, you need to input corresponding commands. It could be complicated for common users. Users are required to input commands in the following command format:

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

There are two basic modes to use: regular & extensive. The extensive mode has two advanced modes according to different recovery options: Segment mode and Signature mode. Regular and Segment mode support only NTFS File System.

Step 1. Download and install Windows File Recovery in Microsoft Store.


Step 2. Input Windows File Recovery in the search bar and select “Run as administrator” to launch Windows File Recovery.


Step 3. View the File System of your hard drive. Right-click your Local Disk (C:) and select “Properties”.


File system


Recommended mode


Deleted recently



Deleted a while ago



After formatting a disk



A corrupted disk


FAT and exFAT



Step 4. There are some common parameters and switches to use. Find the meaning of those in the following chart.

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


Step 5. Here are some common examples for reference.

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

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

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

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

Free & tiny tool-Windows File Recovery GUI

From the information above, it’s difficult for ordinary users to run Windows File Recovery correctly. Here is a Windows File Recovery GUI-WinfrGUI, fully invoking the function of Windows File Recovery with a graphical user interface.

WinfrGUI is a free and tiny tool to help all users utilize Windows File Recovery simply with clickable icons.

Step 1. Download and install WinfrGUI on your computer.

Download Freeware Win 10 2004 and above
Secure Download

Step 2. Select a partition to scan and a location to save recovered files.


Step 3. Choose a scanning mode. Quick Scan and Deep Scan. Only Deep Scan supports Non-NTFS File System. You could also target file types and folders to scan in “Advanced Settings”.


Step 4. Click “Start Recovery” to start the process. Wait for the scanning to complete patiently.


The easiest way to recover files from a hard drive

If you find you couldn't recover files from the hard drive via using cmd and don't have any backup, the easiest way to recover files from hard drives is a professional data recovery program-AOMEI Data Recovery for Windows. This hard disk recovery tool is free software that can help you recover lost files from your hard drive.

It is a tool that knows everything about your hard disk and allows you to recover any data from hard drives. It's very simple to use, even for computer beginners. It will assist you in finding and recovering your data in kinds of data loss scenarios. 

AOMEI Data Recovery for Windows

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

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

Step 1. Download and install AOMEI Data Recovery for Windows on your computer. Select a partition of the hard drive, and click "Start Scan". 


Step 2. The program runs the scanning process quickly and deeply to find deleted files and other missing files in the partition.


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


To sum up

To recover files from hard drives using CMD, you could try inputting the attrib command in CMD to recover hidden files from the hard disk. If you accidentally deleted files from a hard drive, you could recover files with the Microsoft official command-line app-Windows File Recovery.

Because it’s not easy for everyone to input the right commands to recover deleted or lost files from hard drives for Windows 10/11. You could try the free hard drive data recovery software-AOMEI Data Recovery for Windows to restore files with simple clicks.

However, Windows File Recovery isn’t a panacea to help you to recover all deleted files. Making a regular backup is the best way to avoid data loss. To keep your data safe, you could try AOMEI Backupper to back up partitions & disks and restore data when you need.