Command Prompt is one of the convenient built-in utilities in Windows that allows users to have full control over their computer. It can be very helpful in recovering files that have been deleted accidentally, lost due to corruption, or after a virus infection. You can use CMD to recover deleted or corrupted files from your computer's hard drive, USB flash drive, pen drive, memory card, or any other external hard drive.
In comparison with professional data recovery software, command prompt data recovery has its own pros and cons.
Advantages:
Disadvantages:
Read on to learn how to use the CMD's attrib command to restore hidden files from a USB, or other command line options to recover data from a USB or hard drive. If the CMD methods fail, you can also use the Tools Data Recovery Wizard to retrieve files from a USB.
Below, you will learn about some specific command-line data recovery scenarios, including how to recover files from a virus-infected hard drive, restore files from a damaged hard drive with bad sectors, and get back inaccessible files from a RAW drive.
Recovers files that have been deleted, lost, hidden, or even infected with a virus.
Supported Devices: Internal/External Windows HDD, USB, SD Card and other storage devices
The attrib command only works on hidden files. If your file has gone missing, you can use the attrib command to check if it was accidentally or maliciously hidden. For other cases of data loss, such as formatting, RAW partition, or deleted files, the attrib command won't work.
Step 1. Insert the hard drive, memory card, or USB flash drive into your computer.
Step 2: Open the Start menu, and type "cmd" into the search bar, then hit Enter. You'll see a program called "cmd.exe" in the list.
Step 3: Right-click on "cmd.exe," and you will get a Command Prompt window that you can use to restore your virus-infected files.
Type in "attrib -h -r -s DriveLetter:\*.* /s /d", replacing "DriveLetter" with the actual letter of your drive, such as "attrib -h -r -s G:\*.* /s /d".
(Replace G with the drive letter of the hard disk drive or external storage device that contained the missing file.)
Applies to: Deleted File Recovery, Recycle Bin File Recovery
Supported Devices: Windows Hard Drive, Desktop
If the files were sent to the Recycle Bin, you can right-click on them within the Recycle Bin and choose to restore them to their original locations before emptying it. Alternatively, you can use command lines to restore them.
Note: The Command Prompt can only recover files that are still in the Recycle Bin and not those that have been permanently deleted or are no longer on your hard drive. If you want to restore files from an emptied Recycle Bin, follow this guide instead.
Step 1: Go to the Start menu and type cmd in the search bar, then hit Enter. Click on "cmd.exe" in the list of programs to open the Command Prompt.
Step 2: Type start shell:RecycleBinFolder and press Enter.
Step 3: Choose the files you want to restore.
Applies to: RAW File System or Damaged File System Recovery
Supported Devices: RAW drives, inaccessible external HDD/USB/SD card
If you lost files on an external drive, connect it to your computer before proceeding. Open the Command Prompt in Windows. If prompted, log in using an administrator account and password.
Step 1. Type chkdsk drive-letter: /r/f in the Command Prompt window (for example, chkdsk d: /r/f; replace "d:" with the drive letter of the storage device where the lost file was stored).
The next sentence only needs to be translated into American English: ""
2. In the Command Prompt window, type diskpart, and then press Enter.
Then type rescan
and press Enter.
4. Exit DiskPart, and in the CMD, type chkdsk /f d: (replace d with the drive letter of your storage device that had the lost data), and press Enter.
Wait for the process to complete, then check your device to see if your lost files are back. If you weren't able to recover your lost files with the above command prompt methods, or need to recover data from a more complex situation, like recovering data from a lost partition on Windows 10/8/7, check out the powerful tool – Data Recovery Wizard below that can help you out.
Since the Command Prompt is not capable of retrieving files in many instances, such as recovering data from a damaged hard drive, formatting a hard drive, or restoring files emptied from the recycle bin, you need a CMD alternative for USB file recovery.
Data Recovery Wizard can completely replace the command prompt, allowing you to:
To restore files from a USB or flash drive without using CMD, follow these steps.
Step 1. Select the disk and start scanning
Launch the Disk Drill Data Recovery Wizard and hover the mouse over the partition where you lost the data. It can be an internal hard drive, an external disk, USB, or SD card. Then, click “Scan.”
Step 2: Preview and check the scanned files
Use the file type filter on the left or in the top-right corner to narrow down the scan results until you find the file you need. Then, you can click the "Preview" button or double-click the file to preview its content (if available).
Step 3: Recover the lost data to a secure location
Check the boxes next to the missing files and click “Recover” to restore your lost data to a secure location. We recommend that you do not save the recovered data on the same disk where it was lost.
This article covers all the command lines for recovering hidden files, retrieving data from the Recycle Bin, and fetching files from RAW partitions. Follow the examples carefully, as incorrect command lines can exacerbate data loss issues.
tools Data Recovery Wizard is a user-friendly file recovery tool that can help you restore deleted or lost files with just a few clicks. If you're new to computers and unsure how to use command prompt to recover files from a USB, we highly recommend giving this simple data recovery software a try.
Below are some very relevant questions on how to recover files using CMD. If you have any of these issues, please refer to the brief explanations.
In the Command Prompt (CMD), the `attrib` command is used to view or change the attributes of files and directories. These attributes include Hidden, Read-Only, System, and Archive. By using the `attrib` command, you can display hidden files, set or clear specific file attributes, or restore files with incorrectly set attributes. For example: - `attrib +h filename` adds the hidden attribute to the filename. - `attrib -r filename` removes the read-only attribute from the filename. - `attrib -s -h -r filename` removes the hidden, system, and read-only attributes from the filename. - `attrib /s /d *.*` lists the attributes of all files and directories in the current directory and its subdirectories. To learn about more usage details, type `attrib /?` in the CMD for help information.
The `attrib` command allows MS-DOS and Windows command line users to change the attributes of a file or folder. For example, you can use the `attrib` command to unhide a hidden file. The `attrib` command is available in all versions of Windows, including Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, and earlier versions of Windows. You'll need to open Command Prompt to use it.
How can I recover files from a damaged USB device?
Has your USB flash drive become corrupted? How to recover and open files from a damaged USB drive? Use Data Recovery tools to retrieve files from damaged, corrupted, or formatted HDD, SSD, USB flash drives, external hard drives, USB sticks, SD cards, CF cards, and more.
Step 1. Connect the broken USB flash drive to your computer and launch the USB data recovery software on your PC.
Step 2. Select your USB drive, which will be labeled as Removable Disk, and click “Scan” to start looking for your files.
Step 3: Preview and recover all files from the corrupted USB drive.
How do I assign a letter to a flash drive using the Command Prompt?
Follow these steps to use the CMD's attrib command to recover files from your USB flash drive:
Step 1: Right-click the Windows icon and search for cmd in the search bar.
Step 2: Right-click the Command Prompt and select "Run as administrator." If prompted, log in with an administrator account.
Step 3. Type: attrib -h -r -s G:\*.* /s /d (replace G with the letter of the drive you want to show hidden files on) and press Enter.
How can I recover lost or deleted files using CMD with UTF-8 encoding?
You can use the attrib command to recover hidden files from hard drives, flash drives, USBs, and other storage devices. You can easily restore deleted files in Windows 10, 8, or 7 through the Command Prompt with the following commands:
Step 1. Press the Windows + R keys simultaneously, and type CMD in the search box.
Step 2: Type chkdsk drive letter:/f in the Command Prompt window and press Enter. (For example, chkdsk D: /f)
Step 3: Press Y for 'Yes' until the command line prompt appears again. Type in the letter of your drive and press Enter.
Step 3: Type the drive letter, and press Enter.
Step 4. Type in /f -> attrib -h -r -s G:\*.* /s /d. This command will restore all hidden files on the storage device.