0

The following batch file is meant to check if a command line parameter is equal to a certain value. If so, it should delete one file, if not, another file should be deleted. But it is not working, and neither file is getting deleted. What is wrong?

@echo off
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
if %1 == "XXX" # also tried if %1 == "XXX" 
   del BBBB.txt
else
   del CCCC.txt
ENDLOCAL

1 Answer 1

2
@echo off
SETLOCAL ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION

if "%~1" == "XXX" (
   del BBBB.txt
) else (
   del CCCC.txt
)

ENDLOCAL
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.