Home > Back-end >  If variable A = variable B do something in batch file
If variable A = variable B do something in batch file

Time:07-23

I am working on a batch file where I need to compare each line of for loop A and for loop B in order to execute another command, but I can't seem to figure this one out. Any help would be greatly appreciated. The code I have so far is listed below.

@echo OFF
SetLocal EnableDelayedExpansion
for /f "delims=" %%A in ('Type "%Paths%"') do (echo %%~nxA)
pause
for /f "delims=" %%B in ('Type "%Names%"') do (echo %%B)

CodePudding user response:

I adapted the linked duplicate to your requirements (untested, because I have no exact information about your source files)

@echo off
setlocal enabledelayedexpansion

<"%NAMES%" (
  for /f "delims=" %%A in ("%PATHS%") do (
    set /p b=
    if "%%~nxA" == "!b!" (
      echo here zip "%%A" 
    )
  )
)

CodePudding user response:

Here you go (:

@echo off 
SET A="welcome to stack overflow"
SET B="welcome to stack overflow" 
if %A%==%B% echo "A and B match"
  • Related