How to delete files and folders using Command Prompt in Windows 10

Delete files & folders using Command Prompt

Sometimes, all our attempts to delete files or folders via the File Explorer give no results. There are several reasons for failure, which can lock files / folders and prevent them from being deleted. In this case, you can use the Command Prompt at delete files, folders, and subfolders.

Delete files and folders with the help of the command prompt

First, incorrect use of the command prompt can render your system unusable and at this point you will not be able to recover deleted files. Proceed with caution and use extreme caution.

There are several ways to delete a file or folder on your Windows system. You may experience problems if the file is locked. It is here that the command line prompt finds its true utility.

To delete files using the command prompt, make sure to open it with administrator privileges.

1) Delete the desired file

When the CMD window opens, navigate to the folder where the file is available. You will have to use the command "cd" or change directory. Then use the following command with options in the prompt:

DEL /F /A 

Right here:

  • / F means forced deletion
  • / A selects only files with the attribute Ready for archiving

2) Delete the desired folder

Navigate to the folder containing the folder you want to delete using the 'cd' command. Type the following command in the command prompt:

RD /S 

Right here:

  • RD deletes the directory folder.
  • / S deletes all subfolders and files

If you also use the / Q parameter, the O / N confirmation will not be required.

If the folder or file is locked, you can follow these instructions to delete locked and non-erasable files and folders.

Try this and let us know in the comments section below if the method is right for you. You can use the same commands with the help of PowerShell.

Leave a Reply

Your email address will not be published. Required fields are marked *