Permanently Delete Files and Folders in DriveB using a DOS Batch File
In this article, we will discuss how to create a DOS batch file to permanently delete files and folders from a specific folder in DriveB. This method is useful when you want to ensure that deleted files cannot be recovered.
Why Permanently Delete Files?
When you delete a file or folder, it is usually moved to the recycle bin, where it can be easily restored. However, there may be situations where you want to ensure that deleted files cannot be recovered. For example, if you are disposing of a computer or hard drive, you may want to permanently delete sensitive data to prevent unauthorized access.
Creating a DOS Batch File
A DOS batch file is a script file that contains a series of commands that are executed in sequence. To create a batch file that will permanently delete files and folders from DriveB, follow these steps:
- Open a text editor, such as Notepad.
- Enter the following command:
erase /Q DriveB:\*This command will delete all files and folders in DriveB. The /Q switch is used to force deletion without prompting for confirmation.
- Save the file with a .bat extension, such as "delete\_driveb.bat".
- Copy the batch file to DriveB.
- Double-click the batch file to run it. Confirm that you want to delete all files and folders in DriveB when prompted.
Adding a Confirmation Prompt
If you want to add a confirmation prompt to the batch file, you can use the following code:
echo Are you sure you want to delete all files and folders in DriveB?
echo Press Y to continue or any other key to cancel.
set /p confirm =
if /i "%confirm%" NEQ "Y" goto end
erase /Q DriveB:\*
:endThis code will prompt you to confirm that you want to delete all files and folders in DriveB. If you press Y, the deletion will proceed. If you press any other key, the deletion will be cancelled.
References
Types of references used: online resources.