Page 1 of 1

MD problem - Two word variable

Posted: 29 Nov 2013 12:49
by colmac
Hi folks

Bit of help please for a new member. I'm creating a batch file to create directories from user input, of football team names.

I'm having problems with the last line of this code

Code: Select all

@ECHO OFF
SET /P hteam=Please enter Home Team : 
SET /P ateam=Enter Away Team : 
SET /P tourn=Enter Tournament : 
SET /P venue=Enter Venue : 
SET /P day=Enter 2 digit DAY Date : 
SET /P mth=Enter 2 digit MONTH Date : 

Path = c:\test\
md %mth%"-"%day%" - "%hteam%" v "%ateam%


It does exactly what I want, until I use a two word variable in either the home team or away team variables (hteam or ateam)

If I enter "aaa" for hteam, "ccc" for ateam and todays dates, I get one directory created as follows

11-29 - aaa v ccc

However, if I enter "aaa bbb" for hteam, "ccc ddd" for ateam and todays dates, I get three directories created as follows

11-29 - aaa

bbb v ccc

ddd

Instead of what I want as

11-29 - aaa bbb v ccc ddd

The variable works perfectly, if i use echo %hteam% it reports back "aaa bbb", so the problem is obviously with the MD command.

Is there a simple way to resolve this.

Thanks

Colin

Re: MD problem - Two word variable

Posted: 29 Nov 2013 13:17
by ShadowThief
Putting the team names in quotes when entering them solves the problem for me. For some reason, wrapping the set commands in quotes doesn't work.

Re: MD problem - Two word variable

Posted: 29 Nov 2013 16:37
by colmac
Excellent, that works.

Thanks very much

Colin