DosTips.com

A Forum all about DOS Batch
It is currently 08 Feb 2016 15:04

All times are UTC-06:00




Post new topic  Reply to topic  [ 8 posts ] 
Author Message
PostPosted: 11 Apr 2012 15:44 
Offline

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

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


Top
   
PostPosted: 11 Apr 2012 23:31 
Offline
Expert

Joined: 16 May 2011 08:21
Posts: 1426
Location: Flanders(Belgium)
'
save as 'batch.CMD' and doubleClick to see instructions of set
Code:
@echo off &set /? |more


Top
   
PostPosted: 12 Apr 2012 00:21 
Offline

Joined: 15 Feb 2012 14:02
Posts: 163
Should I use SET /A alias?


Top
   
PostPosted: 12 Apr 2012 01:09 
Offline
Expert

Joined: 13 Jan 2012 21:24
Posts: 469
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.


Top
   
PostPosted: 13 Apr 2012 01:22 
Offline

Joined: 15 Feb 2012 14:02
Posts: 163
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.

Top
   
PostPosted: 13 Apr 2012 02:00 
Offline
Expert

Joined: 30 Aug 2007 08:05
Posts: 765
Location: Germany
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


Top
   
PostPosted: 13 Apr 2012 02:58 
Offline

Joined: 15 Feb 2012 14:02
Posts: 163
inname is not a command. Somebody told me to use alias command, but that's linux command.


Top
   
PostPosted: 13 Apr 2012 06:05 
Offline

Joined: 23 Dec 2011 13:59
Posts: 2979
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.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 8 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Bing [Bot] and 18 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® Forum Software © phpBB Limited