Command Line to Recover Lost Files on SD/USB/HD in Windows 11/10/8/7


Command line is a very useful tool for us to solve problems like data recovery. This article shares all the situations of data recovery which can be solved by command line, like how to recover lost files from different media on Windows PC including Windows 10, 8.1/8, 7, Vista and XP using command prompt, and introduce a utility which can help you make it in the easiest way.

Can You Recover Lost Data with Command Prompt?

recommendSince CMD is complicated for non-techie users, we would recommend 12 free flash drive recovery software instead of cmd; 5 freeware for android phone recovery that are easier and better than cmd.

Is it possible for you to recover lost files from a hard drive, external HDD, USB flash drive or memory card with help of command prompt?

More than one person has asked the same question. See following case:

"My external hard drive stopped working after dropping on floor. I am wondering if I can run command prompt to recover lost data from the corrupted external HDD."

This user ran into one of the most common data loss situations. As you know, files probably got lost from various digital devices due to more other reasons like deleting, formatting. Then, can you restore all lost files using CMD in every data loss problem? Well, every lost file in any case is recoverable, but CMD has nolimited ability to recover your any data.

Recovering files from usb/memory card/disk with: attrib -r -a -s -h /s /d

  • Open cmd
  • Connect your device to computer
  • Typle 'f' when f is your device drive letter (Replace it with your own one)
  • Type ' attrib -r -a -s -h /s /d'

Video - how to recover deleted files from storage media using attrib

You may want to read: 4 ways to recover files from flash drive with cmd

Restore Data from Virus Infected Media by CMD

Virus infection may hide some or even all files stored on a storage media. In this situation, you can show hidden files and get back all of them by CMD. If it is a memory card or flash drive, you need to connect it to your Windows computer.

Step 1: Run CMD Command

Use cmd to fix error you need to format the disk in drive

Step 2: Type "attrib -s -h -r c:/*.* /s /d" (c: is the drive letter). This command will show all hidden files in C drive.

type cmd to recover files

You can also watch this video tutorial about how to find your hidden files by CMD command:

If the command line fails to find all hidden or missing files from a virus infected memory card, flash drive or hard disk, please try iCare Data Recovery Free to find more lost files.

CMD Fix Bad Sectors without Losing Files

When a hard disk or USB hard drive has bad sectors, you can run CHKDSK from command prompt to scan and repair bad sectors on it. After running CMD, you can type the command "chkdsk drive letter: /r/f" (e.g. chkdsk d: /r/f)

Step 1: run CMD command

run cmd

Step 2:you can type the command "chkdsk drive letter: /r/f" (e.g. chkdsk d: /r/f)

cmd recovery

This command is able to fix bad sectors on the selected drive without touching any file. For the security of data, it is recommended to make a backup before using this command.

Also read: how to repair bad sectors

Run Command Line on Windows XP/Vista/7/8/10

CMD is a command that can be launched on any Windows operating system. The methods to access command line are various on different Windows. Here are some common methods:

1. Click "Start" button > "Run" > type "cmd.exe" and press Enter button

2. For different Windows

  • Go to "Start" button > "Programs" > "Accessories" > "Command Prompt" (Windows XP)
  • Go to "Start" menu > type "command prompt" to show this command and then click it (Windows 7, 8, 8.1 and 10)

3. Click "My Computer" and open C: > Windows > system32 > cmd.exe to create a command prompt shortcut

How to Delete Files Using CMD

You can run CMD to delete files from a hard disk or USB disk following the tutorial below:

Step1. Click "Start" > "Run > type "cmd" to launch command prompt.

Step2. Type the command

E.g. If you want to delete a fine named 111.txt located in D drive 456 folder, you can type "del/f/s/q d:\456\111.txt" and press Enter button. This option delete the 111.txt file but not erase the 456 folder. If you want to delete the file with the folder containing it, you can type "rd/s/q d:\456" and press Enter button.

list media

Files deleted using CMD won’t go to recycle bin, but be deleted immediately. Therefore, you cannot recover deleted files from recycle bin, but need to rely on data recovery software.

Also read: recover deleted files from recycle bin

Data Recovery after Format Command Line

If you want to recover files after format, you cannot run command line to complete it because this command is not helpful with format recovery. A format recovery tool is needed for files restoring after formatting or reformatting.

Try this following free recovery tool to retrieve lost files.

recover files

Read More

Recommend: how to recover formatted hard drive

Convert RAW to NTFS / FAT32 without Losing Data Command Line

Running command line, users can fix some errors under different Windows operating system sometimes. Disk drive raw or says not formatted is a common problem that you can run CMD to fix.

Command line is not a professional data recovery tool, during the most situations you can not recover your data by command line. That’s why you need a useful tool to help you with data recovery problem.We will introduce this point later.

Step 1: Run CMD.

Convert memory card with CMD diskpartConvert memory card with CMD diskpart

Step2: Type“format K: /fs:fat32”(K is the drive letter of your SD card)

Then your SD card will be converted into FAT 32 file system, you can use “ntfs” to instead of “fat32” in the command window if you want NTFS file system.

Although you cannot use command prompt directly for file recovery, it is able to help you get rid of data loss problem sometimes.

When any storage device changes to RAW file system, you can run command line to convert RAW to NTFS or FAT32. Can you convert RAW drive to FAT32 / NTFS without losing files using command line? Yes! You can use the iCare Recovery Pro to perform file retrieval from the RAW drive firstly in case of data loss after file system conversion.

To change RAW to NTFS/FAT32 with CMD, you have to choices:

Recommend: Here is the tutorial to use command line for RAW to NTFS or FAT32 conversion: Change RAW to NTFS FAT32 with CMD>>

Data Recovery Software for Files Recovery without CMD

Here, we would like to share an alternative, namely a data recovery tool, for lost files recovery when command prompt fails. Whether you believe it or not, a data recovery utility always provides the best solution for data recovery in all situations. Here, it is recommended to use iCare Data Recovery Pro. It is a user-friendly data recovery program, which can work on all Windows OS for deleted files recovery, format recovery, RAW drive recovery and resolve almost all data loss issues from any media like memory card, flash drive, pen stick, USB hard drive, etc.

Follow this guide for files recovery with software

Free Data Recovery Software Download

Download iCare Recovery Pro Free Edition to restore data from disk drive, usb flash, memory card for FREE that can help recover 1GB data totally free. The developer also offers ways to get code free on its product information page.


It is vital to avoid overwriting files to your drive if it was damaged.

Step1. Free download, install and run iCare Recovery Pro. Select "Deep Scan Recovery" module.

Step 1 to recover data when your computer says”you need to format the disk in drive” Step 1 to recover data when your computer says”you need to format the disk in drive”

Step2. Select the device where data got lost and then wait the software to scan.

select drive for recovery Step 2 to recover data when your computer says”you need to format the disk in drive”

Step3. Preview and save the files you want to recover.

Step 3 to recover data when your computer says”you need to format the disk in drive” Step 3 to recover data when your computer says”you need to format the disk in drive”

iCare Recovery is a very professional data recovery tool which can solve many data loss problems for you. This is a 100% safe software without virus or malware.

How to prevent your data from loss, here are some tips for you:

1. Don’t save all your data to one device. Make a backup at somewhere else will be useful.

2. Don’t install any malware on your computer or mobile phone.

3. Safely eject your USB flash drive, memory card, external hard drive disk from your computer.

4. When you deleted some files from your device, you need to stop put anything on it, rewriting your disk will cause trouble to your data recovery.

Last updated on July 13, 2021

Hot Articles

File Recovery Free > Format Recovery Utility > Howto > SD/USB/HD data recovery cmd