The computers we use to store a large amount of information on a daily basis. This content is organized and saved in the form of files and folders.
The more tasks we perform with our PC, the more information it will store. Whether creating documents, browsing the web, downloading files and even accessing our mail, it generates information that is stored in the memory of our PC.
For this reason, it is quite normal that little by little, our team fills up with folders with information that sometimes we do not even remember and that, in addition to generating a lack of control in our files, occupy unnecessary space on our computer.
The common thing is to get rid of those junk files that are generated; however, many may not be so easily removed. If you try to delete a folder and your computer does not allow it because it is in use, do not worry. There are certain ways to erase all that information.
The procedure to eliminate these annoying files that cannot be deleted is through the Command Prompt or CMD that Windows provides us to facilitate some tasks.
What is CMD and how does it work?
Anyone who wants to use this Windows platform will be able to check the status of their computer, open a web page from a command, run a .bat file and can even delete all unnecessary files or folders. But what is CMD really?
The Command Prompt is a Windows interface that allows you to perform all kinds of tasks on your computer through basic CMD commands. To access it, just go to the Windows menu and type CMD in the search bar.
How to delete files and folders from CMD?
Delete files
Although it is usually faster to delete files from Windows, selecting and deleting each one, we will always have the option to delete files and folders from CMD. This is extremely useful to get rid of all those files that require permissions to be deleted, or those that cannot be deleted because they are being used at the time.
The first thing we have to do is open the command prompt and we will use the DEL command. (Delete) with which we can delete any type of file from our hard drive. In the CMD panel, we will first use the CD command to go to the directory where the files and folders are located.
Once there we will proceed to write the following code: DEL/F/A <file.extension> Parameters F and A will allow us to delete the files, where F is to force the deletion of the file and A to delete the files marked as «ready for archiving ».
Delete folders
The process to delete folders is quite similar to the previous one; however, this time we will have to change the command, and instead of using DEL, we will have to use the RD (Remove Directory) command.
We will have to go back to the directory with the CD command, we will look for the folder that we want to delete and we will have to execute this command: RD / S <folder>
It is very important to add the S parameter, since, with it, we will delete all the subfolders that the original folder contains. In case of not placing it, if the folder we wish to delete has a subfolder, it cannot be deleted.
After carrying out this process, the interface will ask us if we are sure to make the changes (Y / N), we must press the S key to confirm and enter to delete the folder.
How to change permissions to be able to delete locked folders?
There is the possibility that after executing the commands to delete the files or folders an error box will appear and prevent us from carrying out this process. In most cases, this occurs due to permission problems, since we cannot delete a folder without owning it.
Folders can have different permissions and for this reason, some may not be enabled to be deleted; however, we can change this if we are administrators. The first thing will be to go to the folder that we want to change the permission. We will select the properties option and then advanced options.
A window will be displayed and we will see the owner next to an option called change. We will click there to change the owner. We must set ourselves as owners, check the replace owner box, apply and then accept.