In some cases, for whatever reason, Windows will make sure that the provided file is used by the system and prevent it from being deleted. This file situation is very frustrating, especially if you know the file is not in use.
If you are having trouble in deleting any file or folder directly by right-clicking, then you can delete it using cmd. The commands below delete the specific file or folder and place them in the recycle bin:
Here we have created a sample File and a Folder to delete it using CMD:
del command is used to delete a file. Here, we will take our sample file “hello.txt” located at the desktop and try to delete it using the del command in CMD. Follow the steps given below to delete the file:
Step 1: Change the path of the directory in CMD and set it to the path of the file. Type the following command in cmd and press Enter:
Step 2: Delete the file “hello.txt” with following command:
rmdir command is used to delete the entire folder or directory. Here, we will take our sample folder named “Tasks” placed at desktop and try to delete it using rmdir command in CMD. Follow the steps given below to delete the folder:
Step 1: Change the path of the directory in CMD and set it to the path of the folder. Type the following command in cmd and press Enter:
Step 2: Delete the folder “Tasks” with following command:
- How to Create a Bootable Pendrive using cmd(command-prompt)?
- How to Show all the previously connected WiFi Networks using CMD in Windows?
- Useful CMD commands for daily use in Windows OS
- How to create a Shared Folder between two Local User in Linux?
- How to create a Folder without any name and icon in Windows OS?
- How to Hide a Folder in Windows?
- C program to check whether the file is JPEG file or not
- If we delete cookies of a site, we can still logged in without logging again
- How to Delete Google Chrome Browsing History?
- How to play an Audio file using Java
- Reading and Writing data to excel file using Apache POI
- Creating a Cell at specific position in Excel file using Java
- Reading a CSV file in Java using OpenCSV
- Creating Sheets in Excel File in Java using Apache POI
- Automating File Movement on your system
- Junk File Organizer in Python
- Difference between FAT32, exFAT, and NTFS File System
- The Application Manifest File | Android
- Introduction to Microsoft SMB; A network file sharing protocol
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.