Nowadays, flash drives are one of the most used portable storage devices. Many people use them to store files, transfer them between different devices, share data, and even create backups of their important files. It is undoubtedly one of the safest portable storage devices for personal, professional, and academic use. However, nothing is 100% full-proof, meaning you can still lose data from your flash drive. Fortunately, you can still restore your flash drive’s data using a variety of methods. In this article, we will show you four ways to recover flash drive files using CMD. Let’s dig in.
What is CMD (Command Prompt)?
CMD or Command Prompt is a command line interpreter that comes pre-built with every Windows device. It has only one job—it’s to interpret the text-based command lines typed by the user and take proper actions. With Command Prompt, you can perform many actions using a list of command lines. You can use it to move files, format your computer, check your battery status, fix corrupted files, and much more.
However, most Windows users aren’t quite familiar with CMD, and they choose to rely on programs with a graphical user interface (GPU). But sometimes, it’s much easier to use some command lines via CMD to perform actions that could have taken a long time using GPU-based applications. Recovering the flash drive files is one of those. Luckily, using CMD to recover the flash drive files is a much simpler process than performing the same action via programs with GPU. Now, let’s get into the several methods we already announced.
1. Recover Files from Recycle Bin via CMD
Did you accidentally delete an important file recently? If that’s the case, the file should still be in the Recycle Bin of your Windows device. You can just go to the Recycle Bin and restore the file deleted from your flash drive, right? Well, that’s true! But what if you are unable to find the Recycle Bin, or it isn’t opening at all? In this case, you need to use the CMD to open the Recycle Bin and then retrieve the file from it. Therefore, let us demonstrate the recovery of flash drive files using CMD and Recycle Bin:
- Click on the “Search” icon from the “Taskbar,” and type “cmd.”
- Once the “Command Prompt” option appears, click on it. This will open the CMD window on your PC.
- Now, type the
start shell:RecycleBinFoldercommand and click on the “Enter” key. This command will open the “Recycle Bin” folder.
- Next, go through the files in the Recycle Bin and select the ones you want to restore.
- Right-click on the selected files and click on the “Restore” option. The selected files will move to their previous location.
Please note that this method can only be used to recover files that are still in the Recycle Bin, and merely gives you another way to find and open the Recycle Bin folder. If the file you are looking for isn’t available there, you can’t restore it using this trick. On the other hand, if you are still unable to open the Recycle Bin using the steps mentioned above, you can still use GUID (Globally Unique Identifier) to open Recycle Bin. Type the following command in CMD and press the “Enter” key:
This command will open the Recycle Bin folder in the File Explorer window.
2. Try ATTRIB Command to Recover Flash Drive Files Using CMD
The files and directories of your Windows PC don’t only have names. They have various attributes too. These have one very important purpose: access control. Sometimes, viruses and malware attack the flash drives and change the attributes of the files stored in them. That way, the malware makes it look as if the files have been erased from the flash drive. However, in reality, the files are hidden from the eyes of the users without their knowledge. For them, it’s as if the files have been wiped out. To recover such files, you have to fix their attributes. This will make them appear in your flash drive once again.
Here’s how you can use the ATTRIB command to recover flash drive files via CMD:
- Open the “Command Prompt” on your Windows PC.
- Now, enter “X:” and press the “Enter” key. Here, replace “X” with the drive letter assigned to your flash drive. For example, if the drive letter assigned to your flash drive is “G,” the command line should be this: G:
- Next, type the
attrib -h -r -s /s /d *.*command and press the “Enter” key.
- Go to the “File Explorer” window and open the flash drive. You should be able to see all the files once again.
A Brief Explanation of the ATTRIB Command Line
Here’s a short rundown of all the symbols used in the ATTRIB command line:
- -h erases the “Hidden” file attribute.
- -r cancels the “Read-only” attribute.
- -s wipes out the “System” file attribute.
- /d adds attrib and command-line options to the directories.
- /s adds attrib and command-line to all the matching files in the directories and their subdirectories.
- *.* defines that attrib has been applied to all the files belonging to the current directory.
Now, it should be clear that the command performs multiple operations via a single line. That saves you a lot of time and helps you access hidden files.
3. Use CHKDSK via CMD to Recover Flash Drive Files
If your files have suffered from a severe case of corruption, running the CHKDSK utility tool via CMD can help you restore the files. The tool comes pre-built with every Windows PC. This tool allows you to scan different drives and external storage devices to detect corrupted files and fix them. Here’s how you can run the CHKDSK utility tool to recover flash drive files using CMD:
- Press the “Windows + R” keys to open the “Run” dialog box and type “cmd” in it.
- Next, click on the “OK” button to open the “Command Prompt” window.
- Type the
chkdsk X: /rcommand and press the “Enter” key. Here, replace “X” with the drive letter assigned to your flash drive.
- Now, wait for the CHKDSK utility tool to finish the scanning process.
The CHKDSK utility tool will scan the whole flash drive and look for corrupted files. The “/r” parameter of the command tells the CHKDSK utility to fix the corrupted files and recover readable data from them.
4. Using Windows File Recovery for Flash Drive Data Restoration
The previous methods allow you to recover temporarily deleted files, find the hidden files, and even fix the corrupted ones. But none of those methods can help you recover a permanently deleted file. To fix this issue, Microsoft has released WFR, a command-line-based application that allows you to recover permanently deleted files.
Special Note: You need Windows 10 version 2004 or the later versions to use Windows File Recovery for data rescue. Currently, this tool supports all versions of Windows 11 OS.
To use this method, you need to download Windows File Recovery from Microsoft Store and install it on your computer. After that, follow these instructions to recover your flash drive files using CMD:
- Open the “Command Prompt” window on your Windows 10/11 device.
- Type the
winfr X: C: /xcommand and press the “Enter” key. Here, replace “X” with the drive letter assigned to your flash drive. “/x” represents the different switches. For a better understanding and precise procedure for the type of files you are looking for, check our guide on restoring data using Windows File Recovery.
- Once Windows File Recovery finishes scanning and finds the deleted files, they will be restored in the “C:” drive.