Command prompt (short for CMD), also called cmd.exe, is actually a command-line version of software in the most popular operating systems and it helps you manage disk and partition, delete data, etc as well as perform hard drive data recovery in different situations. It also applies to recover files from flash drive, SD card, etc.
It's frustrating if you accidentally deleted or lost vital data from hard drive due to 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. Be calm and you will get different methods to recover files using cmd in this article.
✍ How to recover files from hard drive using CMD?
❤ In CMD, you could use chkdsk, attrib, rescan, format, etc in different situations.
❤ Besides, Microsoft also release an offline command-line data recovery software to help you recover files in Windows 10 2004 and above. For lower systems or complicated data loss scenarios, try easy & free software - Deep Data Recovery.
In some cases, your files are hidden instead of deleted. To exclude this possibility, try chkdsk & attrib command to recover hidden files from a computer hard disk. The same is true for other storage devices, such as USB flash drives, pen drives, memory cards, etc.
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 drive using CMD.
Step 1. Press the Win + X keys, and select "Command Prompt (Admin)" or "Windows Powershell (Admin)" for Windows 10.
Step 2. Type attrib -h -r -s /s /d *:\*.* and hit Enter. Wait for the command to finish. (Replace * with the drive letter in which you lost files)
✍ Attrib syntax meaning:
If you can't see files in the hard drive or other storage devices, your files are likely to be deleted. In case, you need both chkdsk and attrib command to recover deleted files from hard drive using cmd. Or try to recover files from recycle bin.
Step 1. Open cmd with administrator.
Step 2. Type chkdsk *: /f and press Enter. The * stand for the drive letter of your drive containing deleted files.
Note: The chkdsk command only works for recognized drive. If your drive becomes RAW, you may receive the CHKDSK is not available for RAW drives error.
Step 3. You may be asked to run this command at the next system startup if the drive is locked. Type y and press Enter to confirm this.
Step 4. Restart your system and wait for the disk check process to complete. Type the drive letter in CMD and press Enter.
Step 5. Type attrib -h -r -s /s /d *.* and press Enter.
All the recovered files will be saved in .chk format. You can change them to the original format and save to a new location.
If your files are still not showing in hard drive, you can try to recover deleted files from hard drive with command-line based data recovery software - Windows File Recovery. It also works for external disk and USB drive.
It requires you to learn the syntax, recovery mode and multiple switches. For details, please refer to how to use Windows File Recovery.
winfr source-drive: destination-drive: [/mode] [/switches]
This software has two basic modes: regular & extensive. The extensive mode has two advanced modes according to different recovery options: Segment mode and Signature mode. Regular and Segment modes support only NTFS File System.
Step 1. Download and install Windows File Recovery in Microsoft Store. Input Windows File Recovery in the search bar and select "Run as administrator" to launch Windows File Recovery.
Step 2. View the file system of your hard drive and confirm the recovery mode & switches you will use. Right-click your Local Disk (C:) and select "Properties".
The recovery mode & scenarios:
File system |
Scenarios |
Recommended mode |
NTFS |
Deleted recently |
Regular |
NTFS |
Deleted a while ago |
Extensive |
NTFS |
After formatting a disk |
Extensive |
NTFS |
A corrupted disk |
Extensive |
FAT and exFAT |
Any |
Extensive |
The Winfr.exe switches:
Parameter/switch |
Description |
Supported mode(s) |
/n |
Scans for a specific file by using a file name, file path, file type, or wildcards. For example:
|
|
/y: |
Recover specific extension groups, comma separated |
Signature |
/p: |
Saves a log file of the recovery operation in a different location than the default location on the recovery drive (for example, D:\logfile). |
All |
/segment |
Segment mode, recovery option for NTFS drives using file record segments |
Segment |
/signature |
Signature mode, recovery option for all file system types using file headers |
Signature |
Step 4. Follow the examples below to recover deleted files from hard disk.
winfr C: D: /n \Users\Stephanie\Documents\Test\
winfr C: D: /r /n *Test*
To be honest, the command prompt is not easy to use for most users, especially since these require you to learn a lot. Thus, many users prefer an easy & free software based on GUI, such as Deep Data Recovery.
It is able to recover files from hard drive, external disk, USB drive, SD card, etc in Windows 7, 8, 10, 11, etc and Windows Server and handle different data loss scenarios, such as accidental deletion, virus infection, disk format, system crash, etc.
As for file types, it supports recovering deleted Word documents, Excel files, PPT, pictures, videos, compressed files, etc and more than 200+ types. And the recovered files will retain their original file name, format, quality, path.
Step 1. Download and install this easy & free data recovery software for multiple Windows systems - Deep Data Recovery. In the main page, hover the mouse over the drive and click Scan to scan.
Step 2. The program runs the scanning process quickly and deeply to find deleted files and Raw files in the selected drive. You can search or view files displayed in the following.
Notes:
Step 3. During scanning, you could recover any file you want. Or wait for the final result and select all the files or folders in it. Then, confirm and click "Recover xxx files".
Note: Deep Data Recovery displays the number of lost files to be recovered and their full size. You can use this to determine if you have selected all the lost files on this location.
Step 4. Select a new folder to store the deleted or lost files and click Select Folder to confirm it. It will automatically recover files from hard disk. Don't save them to original location as it may cause data corruption or permanent data loss.
Notes:
Also, your disk may be formatted or ask you to format disk, resulting in data loss. In this case, try the rescan command in the DiskPart tool to recover data from a formatted hard disk.
Step 1. Open CMD with administrator.
Step 2. Type the following commands and press Enter to execute them one by one.
Step 3. Wait for the scan process to complete. It will recover data from a formatted hard disk.
✍ What if your hard drive is a system disk?
If your hard disk contain system partition, you need to boot into safe mode and run CMD to repair disk and recover data from it.
If you suspect your disk is damaged, try the format command in the DiskPart tool. Please recover files from hard disk using above methods first if it contains your important data. Deep Data Recovery is highly recommended because it is suitable for multiple data loss scenarios and multi-system compatibility.
Step 1. Run CMD with administrator.
Step 2. Type diskpart as well as the following commands. Remember to press Enter after each line.
How to recover files from hard drive using CMD? If you not sure if your files are hidden or not, try the attrib command first. You can then use other 5 methods to recover files.
CMD or Windows data recovery program isn't a panacea to help you to recover all deleted files. Thus, making a regular backup is necessary if you are worried about data loss due to unexpected failure. Try free backup software for Windows - Qiling Disk Master Standard.