If input ends with goto

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

If input ends with goto

#1 Post by batchcc » 11 Dec 2015 14:20

I have a batch code which the user inputs text but if the input ends in certain letters I want the file to goto a certain location. Here is an example code

Code: Select all

@echo off 
Cls
Set /p word=
If %word% end with ing goto ing
:ing
Echo ing
Pause

Is it possible to do this? Thanks

miskox
Posts: 631
Joined: 28 Jun 2010 03:46

Re: If input ends with goto

#2 Post by miskox » 11 Dec 2015 14:56

Code: Select all

@echo off 
Cls
set word=&rem
Set /p word=Enter word:
If /I "%word:~-3%"=="ing" goto :ING
goto :EOF

:ing
Echo ing
Pause


This should work.
Saso

Post Reply