Accidentally deleting an important folder on your Windows PC can be a stressful experience, especially if it contains crucial documents, project files, or personal memories. Fortunately, there are multiple ways to recover lost data โ and one of the most powerful yet underrated methods is using the Command Prompt (CMD). In this comprehensive guide, weโll show you exactly how to restore a deleted folder in Windows using Command Prompt, step-by-step, even if youโre not a tech expert.
Table of Contents
- Introduction
- Check the Recycle Bin First (Before Using CMD)
- Method 1: Use the ATTRIB Command to Restore a Deleted Folder
- Method 2: Restore Deleted Folders with Windows File History
- Method 3: Use Robocopy Command to Recover Deleted Folders
- Method 4: Run CHKDSK to Recover Lost Directories
- Method 5: Restore Using Shadow Copies and CMD
- Pro Tips to Prevent Accidental Folder Deletion
- Best Data Recovery Tools (When CMD Is Not Enough)
- Frequently Asked Questions (FAQ)
Introduction
The Restore a deleted folder in Windows using Command Prompt, often known simply as CMD, is a built-in Windows utility that lets you execute text-based commands to perform system-level tasks. While many users rely on graphical interfaces or third-party tools for file recovery, CMD is incredibly powerful and can restore hidden, lost, or accidentally deleted folders in many situations.
Using CMD to restore a deleted folder in Windows offers several advantages:
- No installation required: CMD is already built into Windows.
- Direct control: You interact directly with the file system.
- Advanced capabilities: CMD can reveal hidden files, repair file structures, and restore lost data.
Letโs start with the first and most basic step: checking if your deleted folder is still in the Recycle Bin.
Step 1: Check the Recycle Bin Before Using CMD
Before diving into CMD-based solutions, itโs worth verifying whether the deleted folder is simply in the Recycle Bin. Hereโs how:
- Open the Recycle Bin from your desktop.
- Search for the folder by name.
- If found, right-click > Restore to recover it.
If the folder isnโt there, or you used Shift + Delete
(which bypasses the Recycle Bin), move on to the command-line recovery methods below.
Method 1: Use the ATTRIB Command to Restore a Deleted Folder
The attrib command is one of the most effective ways to restore a deleted folder in Windows using Command Prompt. This command changes file attributes and can help you reveal and recover hidden or system-protected files.
Steps to Use ATTRIB:
- Press Win + R, type
cmd
, and press Ctrl + Shift + Enter to open CMD as administrator. - Navigate to the drive where the folder was deleted. For example:
cd D:\
- Run the following command:
attrib -h -r -s /s /d *.*
Explanation of switches:
-h
: Removes the hidden attribute.-r
: Removes the read-only attribute.-s
: Removes the system attribute./s
: Applies the command to all files in subdirectories./d
: Includes directories.
Result: If the deleted folder was hidden or marked as a system file, it will reappear in its original location.
Method 2: Restore Deleted Folders with File History (CMD Shortcut)
If you have File History enabled in Windows, you can restore a deleted folder in Windows, even through CMD.
Steps:
- Open CMD as administrator.
- Type the following command:
control /name Microsoft.FileHistory
- This will open File History. Click Restore personal files.
- Browse to the folder and click the green restore button.
Even though this method uses a GUI step, launching File History from CMD is faster and often overlooked.
Method 3: Use Robocopy to Recover Deleted Folders from Backup
The Robocopy command is a robust file copy utility that can also be used to restore a deleted folder in Windows,โ provided you have a backup or mirror copy of your drive.
Example Command:
robocopy "E:\Backup" "C:\Recovered" /E /Z /COPYALL
Explanation:
- E:\Backup โ The source drive or folder where the backup exists.
- C:\Recovered โ Destination where files will be restored.
- /E โ Copies all subdirectories, including empty ones.
- /Z โ Enables restartable mode (resumes if interrupted).
- /COPYALL โ Preserves all file information (timestamps, permissions, etc.).
This is especially useful for IT admins and advanced users managing system backups.
Method 4: Run CHKDSK to Recover Lost Directories
If your deleted folder is missing due to disk corruption or a logical error, CHKDSK can help fix the issue and potentially restore the folder.
- Open CMD as administrator.
- Type the following:
chkdsk C: /f
- Replace
C:
with the drive letter where the folder was deleted.
CHKDSK will scan and repair the file system. After the process, check your drive โ sometimes, recovered files appear in a new folder called FOUND.
Method 5: Restore Using Shadow Copies and CMD
Windowsโ Volume Shadow Copy feature automatically creates snapshots of your files. If enabled, you can recover deleted folders by accessing previous versions.
Steps:
- Run CMD as administrator.
- Type:
vssadmin list shadows
- Note the snapshot ID or creation date.
- Use
robocopy
to copy the folder from the shadow copy to your current drive.
This is an advanced method but extremely powerful for restoring older deleted folders.
Pro Tips to Prevent Accidental Folder Deletion
- Enable File History or OneDrive Backup for continuous protection.
- Use Recycle Bin confirmation prompts to avoid accidental deletion.
- Create regular system restore points.
- Use cloud storage or external drives for redundant backups.
Best Data Recovery Tools (If CMD Doesnโt Work)
If none of the CMD methods succeed, you might need professional data recovery tools. Here are some top recommendations:
- Recuva: A free, beginner-friendly tool for recovering deleted files and folders.
- Disk Drill: Offers deep scan and preview options for lost files.
- R-Studio: A professional-grade tool ideal for formatted drives and severe data loss.
- EaseUS Data Recovery: A user-friendly solution for recovering deleted partitions and folders.
Frequently Asked Questions (FAQ)
1. Can I restore a permanently deleted folder using Command Prompt?
Yes, in many cases you can restore a permanently deleted folder using the attrib
, robocopy
, or chkdsk
commands. However, success depends on whether the data sectors have been overwritten.
2. Does CMD work if the folder was deleted a long time ago?
It depends. If the disk space hasn’t been overwritten, CMD may still be able to recover it. Otherwise, you may need professional recovery software.
3. How do I open Command Prompt as administrator?
Press Win + S, type cmd
, right-click on โCommand Prompt,โ and select Run as administrator.
4. Can I recover folders from an external drive with CMD?
Yes, CMD works with external drives too. Just replace the drive letter in your commands with the external driveโs letter.
5. What should I avoid after deleting a folder?
Avoid writing new data to the same drive, as it may overwrite the deleted files, making recovery impossible.
Leave a Reply