How to forcibly delete files and folders from CMD in Windows

For this reason it is quite normal for our team to gradually fill up with folders with information that sometimes we do not even remember and that, in addition to generating lack of control in our files, take up unnecessary space on our computer.

The common thing is to get rid of those junk files that are generated; however, many may not be removed that easily. If you try to delete a folder and your computer won't allow it because it's in use, don't worry. There are a few ways to clear all that information.




The procedure for deleting these annoying files that cannot be deleted is via Command Prompt or CMD that Windows provides us to facilitate certain 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 also delete all unnecessary files or folders But what is CMD really?

How to forcibly delete files and folders from CMD in Windows

The command prompt is a Windows interface that allows you to perform all kinds of tasks on your computer via 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, by selecting and deleting each of them, we will always have the option of delete files and folders from CMD. This is extremely useful for getting rid of all those files that require permissions to be deleted, or those that cannot be deleted because they are currently in use.



The first thing we need 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.


How to forcibly delete files and folders from CMD in Windows

Once there we will proceed to write the following code: DEL / F / A I 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 for deleting 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 command RD (Remove directory).

We will have to go back to the directory with the CD command, we will look for the folder we want to delete and we will have to execute this command:  RD / S

It is very important to add the parameter S, since with it we will delete all subfolders contained in the original folder. In case of not inserting, if the folder we want to delete has a subfolder, it cannot be deleted.

After performing 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 a possibility that after running the commands to delete files or folders an error window appears that prevents us from performing this process. In most cases, this happens due to authorization problems, as we cannot delete a folder without owning it.


The folders may have different permissions and for this reason some may not be enabled for deletion; however, we can change it if we are administrators. The first thing will be to go to the folder whose permissions we want to change. We will select the properties option and then the advanced options.


A window will pop up and we'll see the owner next to an option called edit. We will click there for change the owner. We need to place ourselves as owners, check the Replace owner box, apply and then accept.

Tagsfinestre
add a comment of How to forcibly delete files and folders from CMD in Windows
Comment sent successfully! We will review it in the next few hours.