View unanswered posts | View active topics It is currently 23 Jul 2014 20:09



Post new topic Reply to topic  [ 8 posts ] 
DOS equivalent of ${variable} 
Author Message

Joined: 15 Feb 2012 14:02
Posts: 163
Post DOS equivalent of ${variable}
How to write linux bash
Code:
${path}
syntax in DOS?

Code:
set "path=mypath"
convert image.jpg -resize 50% ${path}image.png


11 Apr 2012 15:44
Profile
Expert

Joined: 16 May 2011 08:21
Posts: 1261
Location: Flanders_(Belgium)
Post Re: DOS equivalent of ${variable}
'
save as 'batch.CMD' and doubleClick to see instructions of set
Code:
@echo off &set /? |more


11 Apr 2012 23:31
Profile WWW

Joined: 15 Feb 2012 14:02
Posts: 163
Post Re: DOS equivalent of ${variable}
Should I use SET /A alias?


12 Apr 2012 00:21
Profile
Expert

Joined: 13 Jan 2012 21:24
Posts: 440
Post Re: DOS equivalent of ${variable}
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.


12 Apr 2012 01:09
Profile

Joined: 15 Feb 2012 14:02
Posts: 163
Post Re: DOS equivalent of ${variable}
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:
inname=`convert image -format "%t" info:`
convert image.jpg ..... ${inname}_%d.png


Last edited by doscode on 13 Apr 2012 03:03, edited 3 times in total.



13 Apr 2012 01:22
Profile
Expert

Joined: 30 Aug 2007 08:05
Posts: 666
Location: Germany
Post Re: DOS equivalent of ${variable}
Expanding of variables are done with percents.

Code:
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.

Code:
echo 100%%


jeb


13 Apr 2012 02:00
Profile

Joined: 15 Feb 2012 14:02
Posts: 163
Post Re: DOS equivalent of ${variable}
inname is not a command. Somebody told me to use alias command, but that's linux command.


13 Apr 2012 02:58
Profile

Joined: 23 Dec 2011 13:59
Posts: 1751
Post Re: DOS equivalent of ${variable}
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.


13 Apr 2012 06:05
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 


Who is online

Users browsing this forum: Bing [Bot], dbenham, Google [Bot], Yahoo [Bot] and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.