How to Delete File Using Batch Script
This article will demonstrate how to delete a file using a Batch script.
Delete File Using Batch Script
Generally, we can easily delete a file by clicking Delete
or pressing the delete
button on the keyboard. But in Batch, we have to follow a general format or syntax.
Syntax:
del filename
We will see the various formats of this command with examples below.
This example will delete a file named test.txt
. This will only work when you are executing this while in the file’s directory.
del test.txt
The below example will delete a file provided by the location.
del d:\test.txt
This command will delete all the type .txt
files in the directory.
del d:\*.txt
Our last example will delete the file from the directory, ending with est.txt
, whatever the file name starts with.
del d:\?est.txt
All of the methods discussed above are only for Windows environments.
Aminul Is an Expert Technical Writer and Full-Stack Developer. He has hands-on working experience on numerous Developer Platforms and SAAS startups. He is highly skilled in numerous Programming languages and Frameworks. He can write professional technical articles like Reviews, Programming, Documentation, SOP, User manual, Whitepaper, etc.
LinkedIn