BATCH file: very stupid question, but HELP ME, PLEASE!!

  • Thread starter Thread starter Capitaneus
  • Start date Start date
C

Capitaneus

I simply want to 'cat' two string passing them as parameter to a
command,
just like this:

[Thecommand] [Param1]

If [Thecommand] is "ps2pdf" and I write

ps2pdf My%Variable%.ttf

anf if %variable% is "font"
then I get

ps2pdf My font.ttf
and not
ps2pdf Myfont.ttf

There is an undesired blank space BEFORE the variable.
The "set /help" talks of the syntax %variable:str1=str2%, but I didn't
understand how it works.

Please, help me...
 
Capitaneus said:
I simply want to 'cat' two string passing them as parameter to a
command,
just like this:

[Thecommand] [Param1]

If [Thecommand] is "ps2pdf" and I write

ps2pdf My%Variable%.ttf

anf if %variable% is "font"
then I get

ps2pdf My font.ttf
and not
ps2pdf Myfont.ttf

There is an undesired blank space BEFORE the variable.
The "set /help" talks of the syntax %variable:str1=str2%, but I didn't
understand how it works.

Please, help me...

There are two topics in your post:

Variable Concatenation
================
If you code
set Variable=font
then the line
ps2pdf My%Variable%.ttf
will resolve to
ps2pdf Myfont.ttf

There will be no space between "My" and "font".
If you have a space then it's because you inserted
it yourself when setting the value for %Variable%,
eg. by coding like so:
set Variable= font

You can easily confirm this by typing this line:
echo Variable=xxx%Variable%yyy

String Substitution
============
The example you mention will substitute a substring
within a variable with something else, e.g. it will turn
"Goldfinger" into "Goldnugget". I do not think that
this is what you want.
 
Back
Top