Using command prompt and PowerShell, you can do almost anything on Windows 10. For instance, you either create or delete files via command prompt with ease. With PowerShell, you can uninstall built-in store apps too. Though you can easily delete files by pressing the Delete key on your keyboard, there might be times when you need to use the commands to delete files. So, in this short tutorial let me show you how to use command prompt commands to delete files on Windows.
Command to Delete Files with Command Prompt
There are multiple ways to delete files with commands on Windows. For instance, you can delete a single file, delete multiple files, delete files with a specific extension, delete read-only files, etc. I've divided the commands into their own sections so that you can find and use them easily.
- Command to delete a single file
- Command to delete multiple files
- Command to delete files with a specific extension
- Command to delete read-only files
Warning: files deleted using the below commands will be deleted permanently. i.e, you cannot restore deleted files from Recycle Bin.
Note: the del commands shown below will also work with PowerShell.
1. Command to delete a single file using Command Prompt
To delete a single file, all you need to do is execute a single command and you are done. Though you can delete files with regular user permissions, it is better to delete files as an administrator.
First, search for cmd in the start menu, right-click on Command Prompt and select Run as administrator option to open elevated command prompt.
Now, use the
cd command to go to the folder where the files you want to delete are located. For instance, the files I want to delete are in a folder named "del" on my desktop. So, I use the following command.
Once you are in the folder, simply execute the below command to delete a file. Don't forget to replace
<filename> with the actual file name with its file extension. In my case, the file name is
When you successfully delete a file, you will not see any confirmation message. However, if there is any problem, the command prompt will show an error message.
2. Delete multiple files with command in Command Prompt
There are two ways to delete multiple files in the command prompt. In the first method, you will specify all the file names manually. This gives you better control over what files to delete. The second method is to use the wildcard. This is useful for bulk delete operations.
2.1 Specify file names manually
When you have multiple specific files to delete, you can manually specify the files names so that the command prompt will only delete those files and ignore all others.
Just like before, open command prompt and execute the below command while replacing <filname1>, <filename2>, etc., with the actual filenames. You can specify as many filenames as you want.
del <filename1> <filename2>
2.2 Bulk delete files with a wildcard in the command prompt
To bulk delete files in a folder, you can use the wildcard
*. This wildcard feature is very useful when you want to delete all files in a folder, delete files with a specific name, etc.
Delete all files in a folder using the below command. Since you are deleting all the files in a folder, Windows will warn you. Simply type Y and press Enter to confirm file deletion.
Delete all files that start with a specific name
Delete all files that contain a specific word.
3. Command to delete files with a specific extension
If you are looking to delete files that have a specific file extension then you can use the below command. Say you want to delete all PNG files in a folder, use the following command. Of crouse, replace "png" with the file extension of your use case.
To delete all files with a specific name and file extension, use the below command. Replace "img" with your filename.
4. Delete read-only file with Command Prompt
If the file you are trying to delete is read-only then the command prompt won't be able to delete even with the admin rights. If you try to delete a read-only file via command prompt using the above command, you will receive "Access is denied" error message.
To delete a read-only file using commands, you need to force it. So, open the command prompt, navigate to where the file is located, and use the below command. Replace <filename> with the actual filename.
del /f <filename>
As an alternative, you can also use this command to delete read-only files in the command prompt.
del /a:r <filename>
As you can see, it is rather easy to delete files from the command prompt. All you need is a single command and you are good to go. If you have any questions or looking for a specific solution, comment below and I will try to help.
If you like this article, you might also like to know how to record screen using VLC or record screen without installing any third-party software and how to delete a single URL from chrome and firefox autocomplete. Do check them out.