Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
doscode
- Posts: 175
- Joined: 15 Feb 2012 14:02
#1
Post
by doscode » 11 Apr 2012 15:44
How to write linux bash
syntax in DOS?
Code: Select all
set "path=mypath"
convert image.jpg -resize 50% ${path}image.png
-
Ed Dyreen
- Expert
- Posts: 1569
- Joined: 16 May 2011 08:21
- Location: Flanders(Belgium)
-
Contact:
#2
Post
by Ed Dyreen » 11 Apr 2012 23:31
'
save as 'batch.CMD' and doubleClick to see instructions of
set
-
Liviu
- Expert
- Posts: 470
- Joined: 13 Jan 2012 21:24
#4
Post
by Liviu » 12 Apr 2012 01:09
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.
-
doscode
- Posts: 175
- Joined: 15 Feb 2012 14:02
#5
Post
by doscode » 13 Apr 2012 01:22
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
Last edited by
doscode on 13 Apr 2012 03:03, edited 3 times in total.
-
jeb
- Expert
- Posts: 1042
- Joined: 30 Aug 2007 08:05
- Location: Germany, Bochum
#6
Post
by jeb » 13 Apr 2012 02:00
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
-
doscode
- Posts: 175
- Joined: 15 Feb 2012 14:02
#7
Post
by doscode » 13 Apr 2012 02:58
inname is not a command. Somebody told me to use alias command, but that's linux command.
-
Squashman
- Expert
- Posts: 4471
- Joined: 23 Dec 2011 13:59
#8
Post
by Squashman » 13 Apr 2012 06:05
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.