Holly
Holly

Reputation: 1

How to create a "warning" in a batch file?

So basically, I do a lot of mod work in my spare time. However, this can create an unnecessarily large amount of files that I want to delete. So, I created a batch file that pretty much deletes every file (image files, model files, etc) but knowing myself, I have a gut feeling that I might one day accidentally open the batch file and screw myself over. What I'm wondering is, is it possible to create a "warning" in the batch file? Such as, "Warning! Proceeding will delete all files that haven't been backed up. Press any key to proceed." being an example? I haven't been able to find someone who has a similar request. Thanks for reading through this! I'd appreciate any help.

TL;DR: When a batch file is opened, is it possible to have a warning message that appears before any commands are run?

Upvotes: 0

Views: 2188

Answers (1)

Magoo
Magoo

Reputation: 80033

@echo off
set /p proceed=warning - enter x to proceed
if /i "%proceed%" neq "x" goto :eof
... now do your thing

You get prompted and must press x and enter to proceed.

Upvotes: 1

Related Questions