Wondershare Recoverit

File Recovery

  • Recovers deleted or lost files from hard drive effectively, safely and completely.
  • Supports data recovery from 500+ data loss scenarios, including computer crash, partition loss, accidental human error, etc.
  • Supports 1000+ file formats recovery with a high success rate and without any quality loss.
Free Download Free Download Free Download Learn More >

How to Recover Deleted Files Using Command Prompt

Wondershare Recoverit Authors

Apr 07, 2024 • Filed to: Recover Files • Proven solutions

"I've got important data that I need to recover from my computer HDD. Is there any simple way to recover files using cmd?"

Windows Command-Line provides a reliable way to recover files from nearly all storage media, memory card, flash disk drive, HDD, SSD, pen drive and any other storage media without the use of software on your machine.

The next question that brings everything into perspective is:

How do you recover files with the command prompt? And can you use the command prompt to recover all lost data? Folks are asking the same question for command prompt data recovery.

To answer that correctly, we'll check if there is any command-line available to execute the recovery.

Command prompt is one of the powerful and applicable Windows built-in utility that enables you to take full control of your computer and could get the work of data recovery done after any data loss-accidental deletion, virus attack, unintended storage formatting, and many more data loss scenarios.


Part 1: How Do you Use CMD to Recover Lost or Deleted Data

2.1 Recover Files from External Drive Using CMD

To recover files using cmd from external drive, we'll use the attrib command.

This command applies to Deleted, lost, hidden, and even virus-infected file recovery.

It supports devices like Windows drive, external HDD, USB, SD card, and any other external storage media.

Note: Remain careful when you follow the command line. A tiny wrong typing error can result in serious problems.

A Step-by-Step Guide Recover Files from an External Drive using CMD

  1. Plug in your external storage media to your system.
  2. Head over to the start menu, and key in "cmd" in the search bar, and hit the Enter key. This will open a pane on the left, showing the command prompt app.
  3. Right-click on the Command Prompt app and select "open as admin" to open the windows of cmd.
  4. On the CMD command line, key in the following command:
    attrib -h -r -s /s /d drive letter:\*.*"

For instance, attrib -h -r -s /s /d H:\*.*" if the drive you wish to recover is H. Replace H with the external drive letter of your external storage media.

Method 2:

  1. Press Windows +R keys simultaneously, and key-in cmd in the search box.
  2. In the command line, key in chkdsk G/f where G is the disk letter you desire to recover.
  3. Press Y until the command line starts again.
  4. Again, enter the drive letter, for this case, G and hit the Enter key. The command line will go back to start.
  5. Enter the following command:
    [G : \ >attrib –h –r –s /s /d *.*] (Replace G with your disk letter)

The command will retrieve all files in the drive.

Here:

After completion of the recovery process, you can create a new folder on the external drive with all recovered files.

The files might come in .chk format. Change the file extension and choose a preferred extension for each file.

2.2 Restore Files from the Recycle Bin Using CMD

This is applicable in recovering deleted files and Recycle Bin File recovery.

If you delete files from the recycle bin, you can either choose to Right-click files in the recycle bin or follow the command lines to restore them to their original location before emptying it.

  1. Head over to the Start menu and key-in cmd the search bar. Then hit Enter. This opens a window on the left of your screen.
  2. Click on the Command Prompt app from the listing of the programs to access its command line.
  3. Key in Start shell: recycle bin folder on the command line and hit the enter button.
  4. Select the files you wish to recover.

Part 2: How to Recover Deleted Files if the CMD Method Fails

Command Prompt ability to recover lost data is limited to a large extent, which means that you may not be able to recover all files using the CMD entirely.

When the CMD command line fails to restore your data, a data recovery tool can be the best alternative.

The only problem?

It is a world of data recovery software. Choosing the correct one can be difficult. So we scrape every corner of the web, executing the hard work for you--including assessing the feature that makes it outcompete its competitors in the data recovery world, to bring you one of the world's best data recovery tools--Recover It--right in front of you. Here is what the tool has to offer to you.

deleted data recovery

Recoverit Data Recovery - The Best File Recovery Software

  • Smart Scan Technology: Employ exclusive smart scan technology that rapidly locates and restore files, even those that other recovery software could never find.
  • Deep Scan Technology: This mode utilizes RAW searching technology with mask capabilities and extended file search, that gets verbose information of a file.
  • Stronger Preview Function: Utilize the powerful, exceedingly optimized preview function that is even better than before.

User Guide: How to Use Recoverit Data Recovery Software

Step 1: Pick a recovery location

Select a target location to execute data recovery and recover files using the command prompt. Next, hit the 'Start' button.

recoverit interface

Step 2: Scan the location you've selected.

Hitting the Start button initiates the scanning process, which takes some time depending on file size.

operations during scanning

Step 3: Preview and Recover

After the scan, hit the Preview button to confirm the file you wish to recover. Then hit the Recover button to get all your lost data back.

save recovered files

Video tutorial on How to Recover Permanently Deleted Files from PC

Recent Videos from Recoverit

View More >
Free Download | Win Free Download | Mac
article-safe-itemSecurity Verified. 3,591,664 people have downloaded it.

Part 3: Why is it Possible to Recover Deleted Files With Command Prompt?

With Command Prompt, you can troubleshoot many problems related to Windows, including hard drive recovery. It is the most powerful Windows-in-built utility which helps users to retrieve lost data.

Besides, this utility from Windows can help you build bad sectors on storage media and convert the RAW file system to NTFS. That's why if you accidentally lose your data you can directly use cmd to regain it.

But before we move ahead, let's dig a little deeper into the file structure to understand how cmd retrieves data.

A file consists of two parts:

  1. A directory, which includes the file name and the list of blocks
  2. The actual block which contains the data.

When you delete a file, your system only removes the directory of the actual blocks, and if not overwritten or modified, the block still contains the data.

Therefore, the directory entries are marked available and are hidden from the operating system.

In such cases, you can quickly recover your lost data using the command prompt.


Part 4: How to Prevent Permanent Data Loss

Nobody dreams of undergoing the data recovery process. Everyone would do what it takes to keep data safe.

And that's what we're going to focus on. And some of the following measures may be helpful.

In the data world, there is nothing that can replace backup to prevent data loss and avoid money-intensive recovery. Backup means that you're keeping at least a copy of the original file, preferably not in the same disk media. And that isn't all, verify your backup frequently. It is a bad surprise to wait until disaster strikes only to find that your backup is corrupted.

While working with your computer, you must adopt healthy practices that can prevent major data loss scenarios, and in the worst-case scenario, will increase the chances of successful recovery.

Some malicious-ware and viruses can infect, delete, or modify your data secretly causing a computer crash and data loss at the same time.

To remedy this, you need a working antivirus and keep it up-to-date. Antivirus software is designed to protect systems from malware and other viruses that threaten your data. Viruses spread through the internet.

Software updates usually exist to patch invisible vulnerability—a vulnerability that can be a threat to your data. For safety purposes, keep your software up-to-date and shun the tendency of postponing updates and regularly check for pending software updates.

Get serious in protecting your hardware by keeping all network components in secure, air-conditioned with low foot traffic to prevent accidents.

What's more, keep and access your system in a place that deters theft, such as video security and 2FA-enabled entry.

Make use of data protection tools that can keep sensitive information out of the wrong hands. These include cloud disaster recovery solutions, firewalls, virtual private networks, antivirus software, and even more, which will go along protecting sensitive data from landing into the wrong hands.


Conclusion

Nothing is more painful than the instant it hits you that your valuable data has to get out of hand and has entered the world of data loss. In a spur of a moment, data that means all to you can disappear suddenly substituted by an excruciating feeling of dismay. But Windows understand such a situation happens. And they present a free method to recover deleted files using the cmd.

However, cmd data recovery has plenty of limitations that a data recovery software can easily overcome. And Recoverit presents free data recovery for the first 100 MB without compromising anything—free recovery quality, and the process is similar to the pro version.

Recoverit author

Amy Dennis

staff Editor

Home > Resources > Recover Files > How to Recover Deleted Files Using Command Prompt