Hello please help me with this one! I would like to check if the user input URL contains the defined SUBSTRING or not. If yes I would like to GOTO LONG else GOTO SHORT
Thank you!
@echo off
setlocal enabledelayedexpansion enableextensions
SET /P "URL= Input the link of the video: "
SET "SUBSTRING=?filter=archives&sort=time"
ECHO !URL! | FINDSTR /C:"!SUBSTRING!">nul
IF ERRORLEVEL 1 (GOTO SHORT) ELSE GOTO LONG
:LONG
SET LINK=1
ECHO THIS IS A LONG LINK
ECHO "THE LINK NUMBER IS %LINK%"
ECHO !URL!
GOTO END
:SHORT
SET LINK=0
ECHO THIS IS A SHORT LINK
ECHO "THE LINK NUMBER IS %LINK%"
ECHO !URL!
GOTO END
:END
pause
So this is the working code. I will now mention the problems I had so others can learn from it
setlocal enabledelayedexpansion
delayedexpansion
disabled I must use percentages instead of exclamation marks when I want to use a variable in a command laterCorrect me if I am wrong but thats what I figured out with these guys' help and on my own by trial and error I made this list and updated the code so if a newbie like me gets stuck they can have a look at this post. Once again thank you guys!
@echo off
SET /P "URL=Input the link of the video:"
SET "SUBSTRING=?filter=archives"
ECHO "%URL%"|FINDSTR /C:"%SUBSTRING%">nul
IF ERRORLEVEL 1 (GOTO SHORT) ELSE GOTO LONG
:LONG
SET LINK=1
ECHO THIS IS A LONG LINK
ECHO "THE LINK NUMBER IS %LINK%"
GOTO END
:SHORT
SET LINK=0
ECHO THIS IS A SHORT LINK
ECHO "THE LINK NUMBER IS %LINK%"
GOTO END
:END
pause