How to Recover Flash Drive Files Using CMD?

Wondering how to recover flash drive files using CMD? Don’t panic! You could find detailed tutorial and an easy alternative here.

Lora

By Lora / Updated on September 13, 2024

Share this: instagram reddit

Why flash drive files get lost?

Though Cloud storage service and sync services are quite well-developed today, some prudent users prefer using USB flash drives to store their files.

Users tend to use flash drives to save backups of their important files or transfer files between devices. But sometimes users suffer from flash drive files loss and find no way to undelete USB flash drive files.

usb-flash-drive

Users tend to use flash drives to save backups of their important files or transfer files between devices. But sometimes users suffer from flash drive file loss and find no way to recover them.

   
   
   
       

How to retrieve lost files in flash drives

       

Hello, yesterday I went to the net cafe to save my files. On their computer, my flash drive works well and it said Trojan removed, but the trouble is that when I open it on my PC my flash drive is empty. Can somebody help me with this problem?

       

- Question from CCM

   

When it comes to the reasons for flash drive file loss, multiple factors can be found.

Accidental deletion. It’s not evitable to accidentally delete files. 
Virus & malware. Viruses can hide and remove your files deliberately. But don’t worry, you could also remove viruses using CMD
Physical damage. Physical damage to the USB flash drive makes the files in it inaccessible. 
Improper ejection. Ejection USB flash drive without clicking Safe To Remove Hardware can do damage to your flash drive and cause corruption and data loss.

Is it possible to restore flash drive files?

Then, is it possible to retrieve files from flash drive? Some users may wonder do deleted files from USB go to the Recycle Bin on their desktops. Actually, they will not.

Instead, they will bypass the trash bin and get removed directly. But don’t be frustrated, they are not irreversible for good.

When you found files deleted/lost from the flash drive, your files are still not really removed from the drive but logically deleted. And then an available space will be generated for new data to write in.

At this time, it is suggested not to use the flash drive anymore, thus improving the data recovery rate.

Then how to recover deleted files from USB using CMD? Check out the following part.

How to recover flash drive files using CMD?

You may have learned that you could use commands like “chkdsk X: /f” to recover your deleted/lost files, but this command is used to check whether there are any errors on the drive and does no help in file recovery.

But you can use chkdsk X: /r to find bad sectors and recover readable information from a corrupted hard drive. That is to say, it can help recover corrupted hard drive files.

Method 1. Perform flash drive data recovery via the Recover command

You may have heard that the “attrib -h -r -s G:\*.* /s /d” can help restore data. But in fact, this command is used to display or remove attributes of files, you could use it to show hidden files.

If you want to use CMD command to recover deleted files from USB, you could utilize the Recover command in CMD.

Notes:✎...
It retrieves readable info from a bad hard drive, requiring its filename and path. 
It only supports restoring 1 file at 1 time, which is very inconvenient.

Step 1. Start Command Prompt > choose Run as administrator.

run-as-administrator

Step 2. Input diskpart > list disk > select disk 0 > list volume > select volume 1. Please replace the number here with the real drive letter of your affected drive.

Step 3. Input recover [drive:][path]filename.

For example: recover d:\photos\travel01.jpg

recover-command-usage

It can retrieve a photo named “travel01” from the d: drive.

Method 2. Recover deleted files from USB using Windows File Recovery

How to recover flash drive files using cmd in batch? Given this, you might as well use Windows File Recovery, an official command-line app, to get your files back.

Before using this tool, you need to choose scanning mode and switches according to your file system & data loss scenarios.

To check the File System, head over to “This PC” > right-click on the flash drive > click “Properties”.

check-file-system-usb-drive

If the File System of your flash drive is not NTFS, then you cannot use Regular mode.

There are two general recovery modes: Regular & Extensive; two advanced modes: Segment & Signature.

To decide which mode to use, refer to the chart below.

File system Scenarios mode
NTFS Deleted recently Regular
NTFS Deleted for a while Extensive
NTFS Formatted disk Extensive
NTFS corrupted disk Extensive
FAT and exFAT Any Extensive

Switches are used to filter your scanning range. To decide which switches to use, refer to the chart below. 

Switches Definition Supported mode(s)
/n Filter the scan range: scans for a specific file with its file name/path/type, etc. All
/y: Recover specific extension groups. Signature
/k Recovers system files. NTFS Segment​​​​​
/u Recovers undeleted files, for example, from the Recycle Bin. NTFS Segment
Notes:✎...
The source drive could not be the same as the target drive.
To get more details, please refer to "How to use Windows File Recovery"

Step 1. Go to Microsoft Store > search for Windows File recovery > click Get to install.

microsoft-store-get

Step 2. After installation, click Open. Choose recovery mode & switches according to your data loss scenarios. Input the command:

winfr source-drive: destination-drive: [/mode] [/switches]

Source drive refers to the flash drive, please input the right drive letter.

Destination drive refers to the destination where you’d like to have the recovered files stored.

winfr-regular-username-jpg

Step 3. Then wait for the recovery. If you choose the Extensive Mode, it will last for a while.

How to retrieve files from flash drive much easier?

For those who find it difficult to use commands, and those who are using Windows OS under Windows 10, is there no way for them to recover files easily?

Rest assured, you still have a great chance to get your precious files back with a professional data recovery tool. When using Windows File Recovery, you may find you can't find the deleted files you want.

MyRecover, specially designed for Windows users, can assist users to detect their deleted or missing files using its advanced scanning methods.

Perform flash drive data recovery in a breeze
Restore deleted data and retain its format, filename, and path. 
Support data recovery from HDD/SSD/USB/SD card, etc.  
Retrieve over 200 types of data, including photos, videos, docs, zip files, etc. 
Highly compatible with Windows OS 11/10/8/7 SP1 &  Windows Server.

Now download this efficient application to start Windows data recovery with ease.

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

Step 1. Run the software > hover the mouse over the drive to click Scan.

select-pen-drive-to-scan

Step 2. While scanning, you could directly recover what is detected or wait for the whole scanning result.

scanning-external-hard-drive

Step 3. You can search the file name or filter files by type, deleted time, and size. Go to Other missing files > select the data you want to recover, for example, Images > Recover x files. Please remember to save these files to another drive.

select-files-to-recover-from-external-hard-drive

Also, you could utilize this tool to recover permanently deleted files in Windows 10.

Related suggestions for preventing data loss

To avoid you from falling into a similar dilemma again one day, here are some sincere suggestions for you.

Plug in & eject the USB flash drive properly every time. 
Keep your flash drive away from liquid, dirt, oil, or other harmful materials. 
Keep your important data backed up regularly. 
Save the backup copies in different places.

To back up files smartly and easily, it is recommended to take advantage of AOMEI Backupper, a good backup tool for Windows users.

In this article, a detailed method on how to recover flash drive files using CMD has been introduced. In addition, a good Windows File Recovery alternative is given as well. Don’t hesitate to use MyRecover to retrieve deleted files in Windows 10/8/7 and 11 easily.

Lora
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.