How to delete files and folders by Command Prompt

There are different ways to delete files in Windows , but you may come across one that can not be deleted . Then the value of the Command Prompt (CMD) stands out , which allows us to delete blocked files or folders directly from a console.

Sometimes we fail in all attempts to delete certain files or folders with File Explorer. And there are many possible reasons that could cause a file or folder not to be deleted . In this situation, the best way to proceed is to delete the folders or files from the Command Prompt (CMD) .

WARNING : Using the command prompt incorrectly could cause your computer to not work. You will also not be able to recover deleted files, so you should proceed with caution.

Delete folder or file from CMD

Delete files

1 . To delete a file from CMD, you must open the Command Prompt with administrator privileges .

2 . Now navigate to the folder where the file is saved with the command cd (change directory).

cd path \ to \ folder

Replace the part ” path \ to \ folder” with the path to the folder where the file you want to delete is.

3 . Then use the following command to delete files in CMD:

del / F / A path \ to \ file.ext

In this command, / F means forced delete; / A selects only files with the ready-to-archive attribute; and path \ to \ file.ext is the path to the file with its name and extension.

Delete folders

1 . To delete a folder in CMD, go to the folder that contains the folder you want to delete using the cd command .

cd path \ to \ folder

2 . Type the following command to delete the folder from CMD:

RD / S path \ to \ folder

Here RD removes the folder from the directory; / S Removes all subfolders and files.

3 . The Command Prompt will ask you to confirm the removal of the folder, and you must press Y to confirm or N to cancel.

If you add the / Q parameter , you will not be prompted for the Y / N confirmation.

Well this is it. Try the method of deleting files and folders from the CMD command line and let us know with a comment how it went.

by Abdullah Sam
I’m a teacher, researcher and writer. I write about study subjects to improve the learning of college and university students. I write top Quality study notes Mostly, Tech, Games, Education, And Solutions/Tips and Tricks. I am a person who helps students to acquire knowledge, competence or virtue.

Leave a Comment