I am new to Batch scripting. I am trying to write a script which parses given command and check if argument with name 'folder 'is present in that command and if not , add that argument with default value.
I have written following script. This scripts executes correctly if argument is missing. But if argument is present , both if and else blocks are executed.
Please help. Thanks in advance.
@echo off
set ARGS=-action generate -folder "Source"
set t=%ARGS%
echo %t%|find "-folder" >nul
if errorlevel 1 (
goto setDefaultFolder
) else (
echo Folder is specified in command
)
:setDefaultFolder
echo Folder is NOT specified in command. User's current directory will be used as Folder.
set folderArgName=-folder
set folderArgValue="