Command Prompt for USB Recovery: Recover Files Using CMD

Jean updated on Aug 13, 2020 to Data Recovery Solution | How-to Articles


This page includes all command prompt for USB data recovery. You can use CMD to recover files from USB flash drive, pen drive, external hard drive, and hard disk drive on the computer. If the command prompt can't help to retrieve files, you can use EaseUS Data Recovery Wizard to recover permanently deleted or corrupted files from USB.

How to recover files from USB using CMD attrib and other command lines
How to recover permanently deleted files from USB with data recovery software

Overview of Command Prompt for USB Data Recovery 

Command Prompt, being as one of the handy Windows built-in utilities that enable users to take full control of your computer, could do you a favor in retrieving files after hiding, accidental deletion, corrupting, or virus infection. You can recover deleted or corrupted files from computer hard disk, USB flash drive, pen drive, memory card, or other external hard drives using CMD.

Compared with professional data recovery software, the command prompt for data recovery has the following advantages and disadvantages.


  • Free to use
  • Pre-installed on Windows, no need to download any more


  • Required to enter the command line manually, not suitable for computer beginners
  • Not as powerful as a professional file recovery tool, you may not be able to restore every lost file by using CMD fully
  • Can't recover files in complex data loss scenarios, like recover permanently deleted files from USB

Read this post and learn how to recover files from USB using CMD attrib to retrieve hidden files, or use other command lines to recover data from pen drive or hard disk. What's more, you can use EaseUS Data Recovery Wizard to recover files from USB when the CMD fails.

How to Recover Files Using CMD

In the following, you're going to learn all data recovery command lines that are available to use in some specific situations, including recover files from virus infected hard drive, recover files from corrupted drive with bad sectors and recover inaccessible files from the RAW drive.

Command prompt's ability in recovering deleted files is restricted to a large extent, which means that you may not be able to fully restore every lost file by using CMD. 
Be careful when you are using the command lines. A tiny wrong type can cause serious results.

1. Recover Files from USB Using CMD Attrib

Applicable to: Deleted, lost, hidden and even virus-infected files recovery

Supported devices: Windows hard drive, external HDD, USB, SD card, etc. storage devices

Attrib command only enables you to recover hidden files. If your files disappeared somehow, you could use the attrib command to check whether the file is hidden by unintentional operation or virus infection. For other data loss cases, such as formatting, partition turning RAW, or files being deleting, attrib command won't work.

Step 1. Plugin your hard drive, memory card, or USB drive to your computer.

Step 2. Go to the start menu, type in "cmd" in a search bar, hit Enter. Then you can see something named "cmd. exe" under a list of programs.

type cmd and open command prompt in Windows

Step 3. Right-click "cmd. exe" and then you will get the command windows that allow you to recover virus-infected files.

Type in "attrib -h -r -s /s /d drive letter:\*.*", for example, "attrib -h -r -s /s /d G:\*.*".

(Replace G with the drive letter of your hard drive or external storage device where you lost files.)

recover virus infected files with attrib command

2. Recover Deleted Files from Recycle Bin Using Command Prompt

Applicable to: Deleted file recovery, recycle bin file recovery

Supported devices: Windows hard drive, Desktop 

If you deleted files to the Recycle Bin, you can either choose to right-click files in the Recycle Bin or follow the command lines to restore them to the original location before emptying it.

Note: The command line can only recover files that are still in the recycle bin, not files that are not in the recycle bin or on the hard drive. If you want to recover files from emptied recycle bin, here are the tutorials. 

Step 1. Go to the start menu, type: cmd in a search bar, and hit Enter. Click "cmd. exe" under a list of programs to open the command prompt.

Step 2. Type: start shell:RecycleBinFolder and press Enter. 

Step 3. Select the files to restore.

recover files using chkdsk command

3. Recover Files from RAW Drive Using chkdsk and rescan Command

Applicable to: RAW file system or corrupted file system recovery

Supported devices: RAW drive, inaccessible external HDD/USB/SD

If you lost files on external storage devices, connect to your computer in advance and open the command prompt in Windows. Log in with your administrator account and password if necessary.

Step 1. On the command window, type chkdsk drive letter: /r/f (e.g., chkdsk d: /r/f) and hit Enter. (Replace with the drive letter of your storage device where you lost files.)

recover files using chkdsk command

Step 2. On the command prompt window, type diskpart, and then hit on Enter.

Step 3. Type rescan and then hit enter.

recover files using diskpart command

Step 4. Exit DiskPart, type chkdsk /f d: in CMD and hit Enter. (Replace with the drive letter of your storage device where you lost data.)

Wait for the process complete, and you can check the device to see if your lost files have been restored. If you didn't restore lost files using the above command prompt, or you need to get back files from more complex situations, such as recover data from lost partition in Windows 10/8/7, EaseUS Data Recovery Wizard with advanced features introduced below can help you figure out. 

How to Recover Files from USB Using the Best CMD Alternative

Since the command prompt is incapable of retrieving files under many circumstances, like restore data from dead computer hard drive, unformat hard drive, emptied recycle bin recovery, and so son, you need a CMD alternative for USB file recovery.

EaseUS Data Recovery Wizard can fully replace command prompt and allows you to:

  • Recover deleted, formatted, and inaccessible data in different data loss situations.
  • Restore photos, audio, music, and emails from any storage safely and completely.
  • Retrieve data from the recycle bin, hard drive, USB drive, memory card, flash drive, digital camera, and camcorder.
  • Repair corrupted Excel, Word, PowerPoint, photos, and videos effectively.

To recover files from USB or pen drive without CMD, do as follows.

Step 1. Select a location to scan.

Launch EaseUS Data Recovery Wizard, hover on the partition, external hard drive, USB, or memory card from which you want to perform data recovery, and then click "Scan".

select a location and click scan

Step 2. Select the files you want to recover.

Wait until the scanning completes. Afterward, select the lost files you want to recover. If you need, double-click the file to preview its content.

Choose files to recover

Step 3. Recover lost data.

After choosing the files, click "Recover" and choose a location on another drive to save the recovered files.

Recover lost data

Final Verdict

This post covers all the command lines to recover hidden files, restore data from the recycle bin, and retrieve files from RAW partition. Follow the examples and be careful. Wrong command lines can make your data loss worse.

EaseUS Data Recovery Wizard is an easy-to-use file recovery tool that allows you to recover deleted or lost files with a few clicks. If you are a computer beginner and don't know how to use command prompt to recover files from USB, we highly recommend you try this simple data recovery software.  

Recover Files from USB Using CMD Attrib FAQ

The following are the highly relevant questions about how to recover files using CMD. Check the brief explanations if you also have any of these problems.

What is attrib command in CMD?

The attrib command allows an MS-DOS and Windows command line user to change the attributes of a file or folder. For example, you could recover hidden files using the attrib command. The attrib command is available in the Command Prompt in all Windows operating systems including Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, and other older versions of Windows.

How can I recover files from a corrupted USB?

Is your USB corrupted? How to recover and open files on a corrupted USB drive? Use EaseUS data recovery program to recover files from corrupted, damaged or formatted HDD, SDD, USB flash drive, external hard drive, Pen drive, SD card, CF card, etc..

Step 1. Connect the corrupted USB flash drive to your computer and launch EaseUS USB data recovery software on your PC.

Step 2. Select your USB drive, which marks as a removable disk, and click "Scan" to start finding your files.

Step 3. Preview and recover all the files from corrupted USB.

How do you attrib a flash drive using command prompt?

Follow these steps to recover files from USB flash drive using CMD attrib:

Step 1. Right-click Windows icon and type cmd in the search bar.

Step 2. Select to run Command Prompt as Administrator. Sign in with your administrator account if necessary.

Step 3. Type: attrib -h -r -s /s /d G:\*. * (Replace G with the drive letter where you'd like to show hidden files) and hit Enter.

How do you use CMD to recover lost or deleted files?

You can use the attrib command to recover hidden files from a storage drive like hard drives, flash drives, USB. etc.. You can follow these commands in the command prompt and easily retrieve deleted files from Windows 10, 8, 7:

Step 1. Press Windows + R key together in a search box, type CMD.

Step 2. In Command Prompt window, type chkdsk drive letter /f and press Enter. ( e.g.: chkdsk D : /f)

Step 3. Press Y 'Yes' until the command lines start again Again. Enter the drive letter and click Enter.

Step 3. Type drive letter : \ >attrib –h –r –s /s /d *.*. This command will recover all hidden files in a storage device

  • -r stands for Read-only attribute that means files are readable and they cannot be changed
  • -s assigns 'System' attribute of the selected multiple files
  • -h command means 'Hidden' attribute to only selected files
  • /S indicates to search the particular path including subfolders
  • /D command involves the process folders 

Was This Page Helpful?


Frequently Asked Questions

1. Why choose EaseUS Data Recovery Wizard?

"EaseUS Data Recovery Wizard is the best we've seen. It's far from perfect, partly because today's advanced disk technology makes data-recovery more difficult than it was with the simpler technology of the past, but it's fast and efficient..."PCMag

"The first thing you'll notice about EaseUS Data Recovery Wizard Pro is that its interface is very clear and uncluttered, with only a small collection of self-explanatory controls. You won't find lots of extra options hidden in a system of hidden menus, either; what you see really is what you get."techradar

"Recover lost files, even after deleting a partition or formatting your drive."Macworld

2. Why cannot I recover 2GB data for free?

It is recommended to check the version installed is Free or Trial because they are different versions.

Trial has data preview function but cannot save any files, while the Free version enables to recover 2 GB files. The default free space is 500 MB and you may share the product on social media to get another 1.5 GB.

3. Why cannot the recovered files be opened?

A file is saved as 2 parts on the storage device: directory info (which is comprised by file name, time stamp and size info, etc.) and data content.

If the files with original file names and folder structures cannot be opened, one possible reason is the corrupted directory info. There is still a chance to recover the data content with the RAW Recovery method in our software.

4. Why isn't it suggested to recover the files back to the original drive?

The storage structure of the lost files would be altered or damaged by any changes on the drive. If you save the recovered files back to the same drive, the original data structures and data content would be corrupted or overwritten, which causes permanent data loss. So you should prepare another disk to save the files.

5. How can I check whether my data is recoverable or not before purchase?

The Free version helps you save 2GB files to better verify the recovery quality of our product before purchase.

6. How long does it take to scan the drive?

It strongly depends on the capacity of your hard drive and the performance of your computer. As reference,most drive recoveries can be completed in around 10 to 12 hours for a 1-TB healthy hard drive in general conditions.

About Data Recovery Wizard

It's super easy to recover 250+ types of files after deletion, disk formatting and virus infection. Click the links and compare the difference of each version.