Folder with space char

Nov 3, 2012
31
0
Hi guys, my batch .btm file isn't work if it runs inside a folder containing spaces in its name. Should i configure the tcmd.ini file to fix it? Thank you
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,688
106
Albuquerque, NM
prospero.unm.edu
Hi guys, my batch .btm file isn't work if it runs inside a folder containing spaces in its name. Should i configure the tcmd.ini file to fix it? Thank you

A little more information would be helpful: Exactly what command doesn't work, and how does it not work? But in general, you should quote any filename that contains spaces, or that might contain spaces.
 
Nov 3, 2012
31
0
Every command i run... also a simple:

@ECHO OFF
ECHO=Hello.>>%~dp0log.txt
EXIT /B

TCC gives unknown command because the dir with spaces is cut:

C:\my dir -> TCC reads C:\my
 
Nov 3, 2012
31
0
These are the steps i follow:

1) I create my cmd batch as above.
2) With TCMD BATCOMP i create the btm file
3) I run the btm file
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,688
106
Albuquerque, NM
prospero.unm.edu
Every command i run... also a simple:

@ECHO OFF
ECHO=Hello.>>%~dp0log.txt
EXIT /B

TCC gives unknown command because the dir with spaces is cut:

C:\my dir -> TCC reads C:\my

Does CMD.EXE handle that line any differently?

Does it work as you would expect if you quote the filename, e.g.

ECHO Hello.>>"%~dp0log.txt"
 
Nov 3, 2012
31
0
Perfect! So is it useful to use quotes also in:

PUSHD %~dp0 ??

I thought that the quotes were unnecessary with %~dp0.

Thank you!!
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,688
106
Albuquerque, NM
prospero.unm.edu
Perfect! So is it useful to use quotes also in:

PUSHD %~dp0 ??

I thought that the quotes were unnecessary with %~dp0.

Thank you!!

There are a few commands like PUSHD, CD, and CDD which 'know' they can only receive one argument, so you can omit the quotes. Still, it's probably best to use the correct syntax; if an argument contains spaces, quote it.
 

Similar threads