Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
How can you compare two variables in dos?
For example:
set test=c:\folder
set example=c:\folderif %test% == "%example%" goto samepath
<noob I know.
Thanks for help

if "%test%"=="%example%" goto samepath
=====================================
If at first you don't succeed, you're about average.M2

It works with the example I provided above but for what I'm trying to do it won't.
I have the user input data into two variables and I want to compare those two variables to see if they are the same.
SET /p folder1="Set path for folder 1"
echo %folder1% > folder1.txt
SET /p folder2="Set path for folder 2"
echo %folder2% > folder2.txtif "%folder1%"=="%folder2" goto samepath
then the program just completely skips that if statement even when I make the paths the same.
Thanks for the help Mechanix!

You might want to change the comparison to
if "x%test%"=="x%example%" goto samepath
I don't know which OS it is but on one of them ""=="" doesn't work.

![]() |
external HD
|
DOS USB Drivers
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |