Adding to File Paths in Batch

August 29, 2010 at 17:56:30
Specs: Windows XP
Alright, here's my code:


set dirz=C:\
SET /P Fol=Type the name of the folder to open:
IF Fol=="" ECHO Please enter something.
IF %dirz%==%source% SET dirz=%dirz%%Fol% & CLS & GOTO EXPLORE
SET dirz=%dirz%\%Fol%
GOTO EXPLORE

The user enters the name of the folder to open, and if Dirz is at C:\, the program simply adds the name of the folder to C:\ to make it look like C:\folder
After that, it needs to add a \ after the path and then the folder name to make it look like C:\folder\subfolder instead of C:\foldersubfolder.
HOWEVER, when trying to open a sub folder, it outputs the Path as
C:\folder \subfolder with a space inbetween C:\folder and \subfolder and gets an error.
How do I prevent it from adding the space?
Help is appreciated, thanks in advance.


See More: Adding to File Paths in Batch

Report •


#1
August 29, 2010 at 18:03:24
IF %dirz%==%source% SET dirz=%dirz%%Fol% & CLS & GOTO EXPLORE

Remote the space between %Fol% and the & symbol.

IF %dirz%==%source% SET dirz=%dirz%%Fol%& CLS & GOTO EXPLORE

Good Luck!

Can I put a question here?


Report •

#2
August 29, 2010 at 18:23:47
Thanks!

Report •

Related Solutions


Ask Question