- How to Delete a File in Windows (several variants)
- Contents
- Delete file to “Recycle Bin”
- How to delete a file (folder) using the menu
- How to delete a file (folder) using the button
- Disable (enable) delete confirmation
- How to recovery files from Recycle Bin
- How to empty Recycle Bin
- How to permanent Delete
- Guaranteed file deletion
- Guaranteed deletion of data on the active disk
- Guaranteed data deletion on inactive devices
- Delete via the Command prompt
- How to delete a file via command prompt
- How to delete a folder via command prompt
- Delete via PowerShell
- Comparison table of options how to delete a file
- cmd Delete Folder – How to Remove Files and Folders in Windows
- Kris Koishigawa
- How to open Command Prompt
- How to delete files with the del command
- How to force delete files with the del command
- How to delete folders with the rmdir command
- How to use the /s flag with rmdir
- Kris Koishigawa
- Delete the Windows.old folder on Windows 10 [HOW TO]
- What is the Windows.old folder and can I delete it?
- How to remove Windows.old folder from Windows 10:
- Solution 1 – Use Disk Cleanup tool
- Solution 2 – Through Command Prompt
- Solution 3 – Use CCleaner
- Solution 4 – Change the security permissions
- Solution 5 – Disable certain devices from Device Manager
- Solution 6 – Use Linux Live CD
How to Delete a File in Windows (several variants)
This basic guide describes in detail how to delete a file (folder) in Windows (several ways): from simple deletion to guaranteed deletion with protection from data recovery programs.
Contents
Delete file to “Recycle Bin”
💡 To select multiple files or folders, hold the special button and press the left mouse button:
- Сtrl — highlight a specific file or folder;
- Shift — selection of a range of files or folders.
How to delete a file (folder) using the menu
- Right-click on a document or folder;
- Select the Delete item;
- Click Yes in the confirmation request.
The file will be deleted to the Recycle Bin.
How to delete a file (folder) using the button
- Highlight a document;
- Press the Del key;
- Click Yes in the confirmation request.
The file will be deleted to the Recycle Bin.
Disable (enable) delete confirmation
- Click on the Recycle Bin can icon with the right mouse button;
- Select Properties;
- Disable the Display delete confirmation dialog.
💡 If you just deleted the desired file, press the key combination Ctrl + Z. This will undo your last action in Windows, the deleted file or folder will return to its place.
How to recovery files from Recycle Bin
- Open the Recycle Bin;
- Select the desired file or folder;
- Right click on the selected file;
- Select Recover.
Restore files
The file will be restored to the folder from which it was deleted.
You can transfer the file (or folder) from the Recycle Bin to the folder you need.
Click and hold the left mouse button on the selected file and drag it to the folder or Desktop you need.
How to empty Recycle Bin
You can delete all files from the Recycle Bin.
- Click on the Recycle Bin with the right mouse button;
- Click Empty Recycle Bin.
Empty Recycle Bin
How to permanent Delete
- Highlight a file or folder;
- Press the key combination Shift + Del;
- Click Yes in the confirmation request.
Permanently delete folder
Guaranteed file deletion
Guaranteed deletion of data on the active disk
For guaranteed data deletion, we use the standard CIPHER utility.
Cipher.exe is a command-line tool (included with Windows 2000) that you can use to manage encrypted data by using the Encrypting File System (EFS)
💡 To overwrite as much data as possible, it is recommended that you close all other applications while running CIPHER / W.
- Run the command prompt as administrator;
- We launch the CIPHER command with the necessary keys.
/W — key, deletes data from available unused disk space in the entire volume. The content is overwritten in three stages, with values: 00, FF and a random number.
:X — work volume label.
Utility Cipher.exe
Guaranteed data deletion on inactive devices
For guaranteed data deletion on inactive devices: unused hard disks, portable hard disks and flash devices, we use the standard FORMAT utility.
- Run the command prompt as administrator;
- We start the format command with the necessary keys.
X – specifies the drive letter (followed by a colon), mount point, or volume name.
/P:count — zero every sector on the volume. After that, the volume will be overwritten “count” times using a different random number each time. If “count” is zero, no additional overwrites are made after zeroing every sector.
To run the utility successfully, you must enter the correct label of the active volume/device.
Utility Format.com
The process can take a long time, especially if a large number is indicated in the rewrite counter.
Delete via the Command prompt
How to delete a file via command prompt
- Run the command prompt;
- Go to the desired folder (cd command);
- Run the del command and the fully qualified file name with the extension.
If there are spaces in the file name, enclose the name in quotation marks.
To delete files from system directories, you must run the command prompt as administrator.
How to delete a folder via command prompt
- Run the command prompt;
- Go to the desired folder;
- Run the RD command.
/S – removes all directories and files in the specified directory in addition to the directory itself. Used to remove a directory tree.
If there are spaces in the directory name, enclose the name in quotation marks.
To delete directory from system directories, you must run the command prompt as administrator.
Delete via PowerShell
The PowerShell command to delete folders and files is Remove-Item.
The synonyms of the Remove-Item command are: del, erase, rd, ri, rm and rmdir, so commands from the Windows command prompt will also work.
Windows PowerShell
X – full path to the file (with extension) or folder.
Recurse – the key indicating the deletion of the content folder.
Comparison table of options how to delete a file
Comparison table on how to delete files and folders.
Deleting data to the Recycle Bin | Deleted data can be restored from the Recycle Bin folder on the Desktop. |
Permanent data deletion | Deleted data can only be restored using special programs. |
Guaranteed data deletion | Deleted data cannot be recovered even by special data recovery programs. But special services and laboratories can still recover deleted data. |
How to delete a file (folder) in Windows was discussed in this article. I hope that now you can delete files or folders in different ways, including guaranteed deletion of files beyond recovery with special programs. However, if you run into any problems, do not hesitate to write in the comments. I will try to help.
cmd Delete Folder – How to Remove Files and Folders in Windows
Kris Koishigawa
Sometimes it’s just faster to do things with the command line.
In this quick tutorial we’ll go over how to open Command Prompt, some basic commands and flags, and how to delete files and folders in Command Prompt.
If you’re already familiar with basic DOS commands, feel free to skip ahead.
How to open Command Prompt
To open Command Prompt, press the Windows key, and type in «cmd».
Then, click on «Run as Administrator»:
After that, you’ll see a Command Prompt window with administrative privileges:
Screenshot of Command Prompt window
If you can’t open Command Prompt as an administrator, no worries. You can open a normal Command Prompt window by clicking «Open» instead of «Run as Administrator».
The only difference is that you may not be able to delete some protected files, which shouldn’t be a problem in most cases.
How to delete files with the del command
Now that Command Prompt is open, use cd to change directories to where your files are.
I’ve prepared a directory on the desktop called Test Folder. You can use the command tree /f to see a, well, tree, of all the nested files and folders:
To delete a file, use the following command: del » » .
For example, to delete Test file.txt , just run del «Test File.txt» .
There may be a prompt asking if you want to delete the file. If so, type «y» and hit enter.
Note: Any files deleted with the del command cannot be recovered. Be very careful where and how you use this command.
After that, you can run tree /f to confirm that your file was deleted:
Also, bonus tip – Command Prompt has basic autocompletion. So you could just type in del test , press the tab key, and Command Prompt will change it to del «Test File.txt» .
How to force delete files with the del command
Sometimes files are marked as read only, and you’ll see the following error when you try to use the del command:
To get around this, use the /f flag to force delete the file. For example, del /f «Read Only Test File.txt» :
How to delete folders with the rmdir command
To delete directories/folders, you’ll need to use the rmdir or rd command. Both commands work the same way, but let’s stick with rmdir since it’s a bit more expressive.
Also, I’ll use the terms directory and folder interchangeably for the rest of the tutorial. «Folder» is a newer term that became popular with early desktop GUIs, but folder and directory basically mean the same thing.
To remove a directory, just use the command rmdir .
Note: Any directories deleted with the rmdir command cannot be recovered. Be very careful where and how you use this command.
In this case I want to remove a directory named Subfolder, so I’ll use the command rmdir Subfolder :
But, if you remember earlier, Subfolder has a file in it named Nested Test File.
You could cd into the Subfolder directory and remove the file, then come back with cd .. and run the rmdir Subfolder command again, but that would get tedious. And just imagine if there were a bunch of other nested files and directories!
Like with the del command, there’s a helpful flag we can use to make things much faster and easier.
How to use the /s flag with rmdir
To remove a directory, including all nested files and subdirectories, just use the /s flag:
There will probably be a prompt asking if you want to remove that directory. If so, just type «y» and hit enter.
And that’s it! That should be everything you need to know to remove files and folders in the Windows Command Prompt.
All of these commands should work in PowerShell, which is basically Command Prompt version 2.0. Also, PowerShell has a bunch of cool aliases like ls and clear that should feel right at home if you’re familiar with the Mac/Linux command line.
Did these commands help you? Are there any other commands that you find useful? Either way, let me know over on Twitter.
Kris Koishigawa
Read more posts by this author.
If you read this far, tweet to the author to show them you care. Tweet a thanks
Learn to code for free. freeCodeCamp’s open source curriculum has helped more than 40,000 people get jobs as developers. Get started
freeCodeCamp is a donor-supported tax-exempt 501(c)(3) nonprofit organization (United States Federal Tax Identification Number: 82-0779546)
Our mission: to help people learn to code for free. We accomplish this by creating thousands of videos, articles, and interactive coding lessons — all freely available to the public. We also have thousands of freeCodeCamp study groups around the world.
Donations to freeCodeCamp go toward our education initiatives, and help pay for servers, services, and staff.
Delete the Windows.old folder on Windows 10 [HOW TO]
Windows 10 and some previous versions of Windows sometimes create a folder called Windows.old.
This folder is usually created when you install a new version of Windows, and today we’re going to explain what does this folder do and how to remove it from Windows 10.
What is the Windows.old folder and can I delete it?
When you install a new version of Windows, such as Windows 10 for example, your system automatically moves your older installation to Windows.old folder.
With this folder available you can easily restore the previous version of Windows if the new one isn’t working properly for you.
In addition, this folder works as a backup, so even if the installation process fails for some reason, your PC can use Windows.old folder to restore the previous version of Windows.
You should also know that you can roll back to the previous version of Windows 10 days after its installation, and after that period ends, Windows.old folder will be automatically deleted from your system.
As you can see, Windows.old folder can be extremely useful since it allows you to restore the previous version of Windows, but many users want to delete this folder since it takes a lot of space on their hard drive.
Keep in mind that by deleting this folder you won’t be able to revert back to the older version of Windows in case there’s any major problem.
Since this folder can take 30GB or more of your hard drive space, today we’re going to show you how to safely remove it from your PC.
Can I delete my Windows old folder? You can easily remove it through Disk Cleanup. Keep in mind that deleting the folder will leave you without a restore point. Another way to remove it is by using Command Prompt or a Linux Live CD.
For more info on how to do that, check the guide below.
How to remove Windows.old folder from Windows 10:
Solution 1 – Use Disk Cleanup tool
Windows 10 comes with a useful little tool called Disk Cleanup that allows you to quickly free up space on your hard drive. This application will scan your hard drive partition for old or temporary files and allow you to remove them easily with a single click.
This tool also allows you to remove Windows.old folder and you can do that by following these steps:
- Press Windows Key + S and enter disk. Select Disk Cleanup from the menu.
- When Disk Cleanup tool opens you’ll need to select which drive you want to clean. Select the drive where Windows 10 is installed and click OK.
- Disk Cleanup tool will now scan your PC for old and temporary files. This process might take a minute or two depending on the size of your partition.
- Check if Previous Windows installation(s) option is available. If it is, check it and click OK. You should see a confirmation message available. Select Delete Files and wait until the previous version of Windows is removed.
- Optional: If Previous Windows installation(s) option isn’t available for you, click Clean up system files button and wait for the scan to complete. After that, select Previous Windows installation(s) and follow the instructions from previous step.
Another way to run Disk Cleanup is to check your hard drive partition properties from This PC. To do that, follow these steps:
- Open This PC.
- Locate your primary hard drive partition and right click it. Choose Properties from the menu.
- Go to the General tab and click the Disk Cleanup button.
- Now follow the instructions described in the steps above.
Solution 2 – Through Command Prompt
Usually, the best way to delete Windows.old folder is to use the Disk Cleanup tool. If you can’t delete it by using Disk Cleanup, you might want to consider using Command Prompt.
Keep in mind that Disk Cleanup is the simplest and the safest solution and you should always use it first. To delete Windows.old with Command Prompt, do the following:
- In the Windows search box type cmd, right-click the first result and select Run as administrator.
- When Command Prompt opens, enter the following lines:
- attrib -r -a -s -h C:Windows.old /S /D
- RD /S /Q %SystemDrive%windows.old
- After the commands are executed, close Command Prompt and check if the Windows.old folder is removed.
Few users reported that they needed to use two extra commands before they can remove Windows.old folder from their PC.
According to them, they had to use takeown /F C:Windows.old /A /R and icacls C:Windows.old /Grant Administrators:F /inheritance:e /T commands to take ownership over the Windows.old folder and remove it.
You can also remove Windows.old folder by using Command Prompt at boot. To do that, you need to start Command Prompt by following these steps:
- Click the Start button.
- Click the Power button, hold the Shift key and choose the Restart option.
- When your PC restarts, choose Troubleshoot > Advanced options.
- A list of options will be available. Select Command Prompt.
Now we need to determine what is your drive letter. If you use Command Prompt during the boot, it’s rather possible that your drive letter will change, so you need to use diskpart tool to find it. You can do that by following these steps:
- Enter diskpart in Command Prompt and press Enter. We have to warn you that diskpart is a powerful tool, so use extra caution while using it.
- Now enter list volume.
- List of all available partitions will now appear. Now you need to locate your drive letter. The easiest way to do that is to compare the size of available partitions. After you find the desired partition, check the Ltr column and memorize its letter. In most cases it should be D, but it might be different on your PC.
- Enter exit to quit diskpart tool.
- Now enter RD /S /Q “D:Windows.old” command and press Enter to run it. Keep in mind that you need to use the correct letter that you got in Step 3. In our case that was D, but be sure to double check it on your PC.
- After running the aforementioned command, Windows.old folder will be removed from your PC. Now you just need to close Command Prompt and start Windows 10 normally.
As we already mentioned, using Disk Cleanup is the safest and simplest way to remove Windows.old folder from your PC, so you should use it always over Command Prompt.
If you decide to use Command Prompt from Windows 10, you’ll have to change the attributes of Windows.old folder.
That can sometimes cause certain issues so it might be better that you use Command Prompt during the boot since it doesn’t require that you change the attributes of the Windows.old folder.
Solution 3 – Use CCleaner
CCleaner is a useful tool that is designed to remove old and temporary files from your PC. Some users use it to remove Windows.old folder, and if you use CCleaner you can remove Windows.old folder by following these steps:
- Start CCleaner and click the Cleaner title.
- Select only Old Windows Installation on Windows and Applications sections. You should find this option in Advanced list.
- Now click the Analyze button to start the scan.
- You should now see how much space does the Windows.old folder take. Click Run Cleaner button and wait until CCleaner removes this folder from your PC.
Solution 4 – Change the security permissions
If you try to delete Windows.old folder manually you’ll probably see an error message saying that you lack the necessary privileges to delete this folder. You can fix this problem by following these steps:
- Locate Windows.old folder, right click it and choose Properties.
- Navigate to the Security tab and click the Advanced button.
- Locate the Owner section and click Change.
- Select User or Group window will now appear. In Enter the object name to select field enter Users and click Check Names. Click OK.
- Owner section will now be changed. Check Replace owner on subcontainers and objects and Replace all child permission entries with inheritable permission entries from this object.
- Click Apply and OK to save changes.
- If you get any security warnings just select Yes.
After changing the permissions you’ll be able to delete Windows.old folder without any problems.
We have to mention that changing the permissions of Windows.old folder can sometimes cause issues with your Windows 10 installation, so you might want to consider using Disk Cleanup tool instead.
Solution 5 – Disable certain devices from Device Manager
According to users, they were unable to remove Windows.old folder due to some driver files that were still in use by their PC. To find and remove those files you’ll need to do the following:
- Locate the driver files that can’t be deleted in Windows.old directory. Usually that are SurfaceAccessoryDevice.sys, SurfaceCapacitiveHomeButton.sys, SurfaceDisplayCalibration.sys and SurfacePenDriver.sys. Keep in mind that these driver files might be different on your PC.
- After you find the problematic drivers, you’ll need to disable the corresponding devices from Device Manager. To do that, press Windows Key + Xand choose Device Manager from the list.
- When Device Manager opens, look for the devices that are related to those drivers. After you find the problematic device, right click it and choose Disable.
- After disabling all the problematic devices, try to delete Windows.old again.
- After Windows.old folder is removed, enable the disabled devices again.
Apparently this issue appears on Surface devices, but if you experience this problem on your PC, feel free to try this solution.
Solution 6 – Use Linux Live CD
If you can’t delete Windows.old folder from your PC, you might want to consider using a Linux Live CD. Windows.old folder is protected by your system, and in order to delete it you need to change certain privileges.
Obtaining the necessary privileges might not be easy for non-advanced users, and if you want to delete Windows.old folder without changing your privileges, you might want to consider using a Linux Live CD.
Simply download any version of Linux and create a bootable media. After that, boot to your PC from a bootable media. After Linux starts, locate and delete Windows.old folder.
After deleting the folder, remove the bootable media and restart your PC.