[Detailed Guide] How to Recover Deleted Files from Computer Using CMD

How to recover deleted files from computer using CMD? This article will show you some detailed steps to retrieve deleted files from laptop/PC on Windows 11/10/8/7.


By Lora / Updated on April 2, 2024

Share this: instagram reddit

Is it possible to recover deleted files using Command Prompt?

Data is extremely important to everyone, whether it is stored on a mobile device, SD memory card, USB flash drive, computer or laptop. It can be a pain if you accidentally delete or lose some important files from your computer. At this point, you may be wondering if it is possible to recover deleted files using Command Prompt? The answer is yes.

CMD, or also known as Command Prompt/Line, is available on most Windows operating systems. It is a free and powerful Windows built-in tool that enables you to take full control over your computer and can complete data recovery after any data loss scenarios, including unintentional deletion, virus attack, accidental storage formatting and more.

Besides, Command Prompt can repair bad sectors on storage devices and converts raw file system to NTFS for free. So if you accidentally delete a file, you can just use the Command Prompt to get it back.

How to recover deleted files from computer using CMD

Now, I am going to share with you how to recover deleted files from computer using CMD. Here, you have three options to recover deleted files using CMD. You can choose one according to your needs.

1. Restore deleted files from the Recycle Bin using CMD

The first is to recover deleted files from the Recycle Bin using Command Prompt. When the Recycle Bin is full, Windows deletes files to make space for newly deleted files. However, these deleted files can still be recovered until the Recycle Bin is emptied. Follow the commands below to restore files from Recycle Bin.

Steps: Press Windows+R > type CMD > type start shell:RecycleBinFolder and hit Enter > right click the files you want to recover and click Restore.

type cmd recycle bin

2. Recover permanently deleted files using Command Prompt in Windows 11/10/8/7

As we all know, if your computer is connected to an extra device such as a flash drive or USB drive, when you delete files from the device, the deleted files will not go to the Recycle Bin. So, if you want to recover these deleted files from an external drive on your computer, you can use Attrib commands to get your data back.

This command applies to deleted, lost, hidden, and even virus-infected file recovery. Follow the steps to recover deleted files from computer using CMD.

Step 1. Press Windows + R to launch Run, type cmd in the dialogue box, hit Enter.

Step 2. In the Command Prompt window, type chkdsk ‘drive letter’ /g and press Enter. (the "g" is your drive letter.) If the file for this volume is being used, close it or type Y to force it to be uninstalled.

Step 3. Type in G and press Enter again. (The command line will go back to the start.)

Step 4. Now, type G: \>attrib -h -r -s /s /d *.* and press Enter, this command will help you recover deleted files in this drive.

attrib cmd


The h command assigns the Hidden attribute to the selected files.
The r command refers to Read-only attribute, which means files are readable but non-modifiable.
The s command assigns ‘System’ attribute to the selected files.
The /s command implies to search the specified path including subfolders.
The /d command includes the process folders.

After completing the recovery process, you can create a new folder on the drive containing all the recovered files.

These files may be in .chk format. Change the file extensions and choose a preferred extension for each file.

3. Retrieve deleted files in laptop/PC using CMD via Windows File Recovery

Windows File Recovery is Microsoft's official data recovery tool, a command-line application that can be used to recover files that have been deleted from your computer. It currently works on Windows 10 2004 and above. You can try its command prompt to recover deleted data on your laptop or PC.

Next, I will show you how to use these commands to recover your deleted files.

Step 1. Firstly, you need go to Microsoft Store to get Windows File Recovery.

microsoft store get

Step 2. Open Windows File Recovery, type the command: winfr source-drive:destination-drive:[/mode] [/switches] and hit Enter. This is the general command line syntax for restoring files via Windows File Recovery. 

For example, if you want to restore files from E: drive to D: drive, you want to use Segment mode, and the files you lost are Docx files, then as shown in the figure, your command is: winfr E: D: /segment /n *.docx.

winfr segment docx

The meaning of each specific command is shown in the figure below.

There are two basic modes to choose from: Regular & Extensive. And Extensive mode includes two advanced modes: Segment & Signature. The file system of the disk determines which mode you use. You can check the file system by clicking This PC, right-clicking the drive where you deleted the file, check the file system Properties to choose the corresponding Mode and Switch according to the following figure.


wfr mode


wfr switch

Step 3. After that, a recovery folder will be created in the destination drive of your choice. You can go to check if the lost data is recovered.

Tip: Novice users may find this option complicated, there is another Windows File Recovery alternative, a 100% free tool named WinfrGUI that can help you get rid of complicated commands to recover deleted files with a graphical user interface.

The easiest way to recover permanently deleted files from PC/laptop

As you can see, the CMD has many complex parameters and lacks a graphical user interface (GUI), so it is a bit technical and complicated for most users. To retrieve your data, you should be careful when entering  the corresponding command.

If you can’t handle it easily, I suggest you to turn to use an easy way to recover deleted files from PC/Laptop. For instance, you can use a professional Windows file recovery software to retrieve your deleted files easily. MyRecover is such a reliable and powerful files recovery tool with a graphical user interface that anyone can easily perform the recovery process.

✿ It can recover more than 200 types of files including photos, videos, images, documents, audios, etc., from all devices or other external hard drives (HDDs/SSDs), SD memory cards.
✿ Apart from recovering deleted files from PC , it also supports many other data loss situations such as accidental deletion, disk formatting, system crash and virus attack.
✿ It perfectly works with NTFS, FAT32, exFAT, ReFS in Windows 11/10/8/7 and Windows Server and its Quick Scan & Deep Scan modes help to recover your data at high speed without any omissions.

Now, free download and install this data recovery software to get back your files in just a few clicks.

Download SoftwareWin 11/10/8/7/Server
Secure Download

Step 1. Open MyRecover on your computer. Hover the mouse over the drive saved deleted files before, and click Scan to scan.

external hard drive start scan

Step 2. It will automatically check the drive for all lost files, and if you find the files you want to recover, don't need to wait for the full scanning process, click the Recover x files button to complete.

recover lost data


To sum up, this post shows you three methods on how to recover deleted files from computer using CMD that you can try to recover your files. However, it is not easy for everyone to enter correct commands to recover deleted or lost files from computer in Windows 10/11/8/7. Therefore, you can try the free data recovery software - MyRecover, recover files with one click.

By the way, regular backups are the best way to avoid data loss. To keep your data safe, you can try to use backup software-AOMEI Backupper to make a regular backup of partitions and disks on your laptop or PC, and restore data when needed.

Lora · Editor
Lora is an editor of AOMEI Technology. She is also a tester and editor of AOMEI Data Recovery Tools. -- "Keep testing, write the most useful tutorials for helping people recover the lost data for Windows and phones" is the most meaningful thing for her. Dedicated to creating helpful tutorials, she hopes her tutorial can assist users to effortlessly solve data loss problems on their personal computers and mobile phones.