Page 1 of 1
DOS equivalent of ${variable}
Posted: 11 Apr 2012 15:44
by doscode
How to write linux bash
syntax in DOS?
Code: Select all
set "path=mypath"
convert image.jpg -resize 50% ${path}image.png
Re: DOS equivalent of ${variable}
Posted: 11 Apr 2012 23:31
by Ed Dyreen
'
save as 'batch.CMD' and doubleClick to see instructions of
set
Re: DOS equivalent of ${variable}
Posted: 12 Apr 2012 00:21
by doscode
Should I use SET /A alias?
Re: DOS equivalent of ${variable}
Posted: 12 Apr 2012 01:09
by Liviu
In addition to Ed's excellent advice, see also
viewtopic.php?p=14700#p14700 and other previous posts of your own. PATH is no different from CD or TAB.
Re: DOS equivalent of ${variable}
Posted: 13 Apr 2012 01:22
by doscode
Nobody understands my question? I don't ask how to set global variable PATH.
I ask how to evaluate/
perform command and set its output to variable.I simplified the original code before posting it here
Code: Select all
inname=`convert image -format "%t" info:`
convert image.jpg ..... ${inname}_%d.png
Re: DOS equivalent of ${variable}
Posted: 13 Apr 2012 02:00
by jeb
Expanding of variables are done with percents.
Code: Select all
inname=`convert image -format "%%t" info:`
convert image.jpg ..... %inname%_%%d.png
You could also use exclamation marks if you use setlocal EnableDelayedExpansion before.
To escape a single percent you have to double it.
jeb
Re: DOS equivalent of ${variable}
Posted: 13 Apr 2012 02:58
by doscode
inname is not a command. Somebody told me to use alias command, but that's linux command.
Re: DOS equivalent of ${variable}
Posted: 13 Apr 2012 06:05
by Squashman
You cannot directly set the output of a command to a variable in batch files like you can with BASH or other linux shells. Batch doesn't know that that back quote means to execute the command before assigning it to a variable.
You need to put the command inside a FOR /F loop and assign the output of the command to a variable from there.