Computing.Net > Forums > Disk Operating System > Compare Variables?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Compare Variables?

Reply to Message Icon

Name: JMidalo
Date: March 30, 2008 at 16:41:31 Pacific
OS: Vista
CPU/Ram: 8 gigs
Product: intel/hp
Comment:

How can you compare two variables in dos?

For example:

set test=c:\folder
set example=c:\folder

if %test% == "%example%" goto samepath

<noob I know.

Thanks for help




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: March 30, 2008 at 19:16:15 Pacific
Reply:

if "%test%"=="%example%" goto samepath


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: JMidalo
Date: March 30, 2008 at 20:38:39 Pacific
Reply:

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.txt

if "%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!


0

Response Number 3
Name: JMidalo
Date: March 30, 2008 at 20:50:27 Pacific
Reply:

nevermind, forgot the % lol


0

Response Number 4
Name: cup
Date: March 31, 2008 at 09:26:24 Pacific
Reply:

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.


0

Response Number 5
Name: Bakers
Date: March 31, 2008 at 11:35:36 Pacific
Reply:

Windows VISTA thought this was a **-DOS Forum ??


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon

external HD DOS USB Drivers



Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Compare Variables?

multiple worded variables and if www.computing.net/answers/dos/multiple-worded-variables-and-if/13652.html

Running variables after a .exe file www.computing.net/answers/dos/running-variables-after-a-exe-file/13737.html

compare from a batch www.computing.net/answers/dos/compare-from-a-batch/11488.html