Is it possible to recall an alias with DOSKEY? Simple example .. I wish to do something like that:
DOSKEY a=someCommand
DOSKEY b=someOtherCommand
DOSKEY c=andAThirdCommand
:: How to do this? -> DOSKEY all=a+b+c
I already know that I can do this by writing this:
DOSKEY all=someCommand ^& someOtherCommand ^& andAThirdCommand
but in the sense of reusing stuff I'd like to reuse my defined aliases from above. Is it possible like I desire?
Thanks!
PS: Saw this here, but it's not a satisfying answer. It seems that it won't work though. :(
Good question, hard to answer... However, I can suggest a workaround with a simple batch script(s).
Suppose we have defined
doskey a=commandA
anddoskey a=commandB
anddoskey c=commandC
macros.Static approach: let's name our script e.g.
dem
(define macro) and place it somewhere in yourpath
. Thendem acb a c b
should define a new macroacb
(ready to further use) as follows:doskey acb=commandA $T commandC $T commandB
. That script could be established by a little adaptation from the scriptdsk
provided (hint: instead of launching a macro text, constitute the text for new macro, but be aware of another escaping).Dynamic approach: let's name our script e.g.
dsk
(doskey) and place it somewhere in yourpath
. Thendsk a b c
should call macrosa
,b
andc
in that sequence. Number of parameters (macro names) passed to script is not limited. The script works well with very simply defined macros, but%
percent sign use like indoskey a=echo %variable%
macro and/or evenfor
loops like indoskey a=for /F "tokens=*" %G in ('dir /b /s *.txt') do @echo %G
;$T
concatenated commands in a macro (equivalent to&
in a batch file) likedoskey a=dir $T set
; done by replacing$T
with&
(in rare cases does not suffice, then need to split and perform commands separately).Known issues and/or restrictions (impossible to resolve without knowing more about real structure of macros used); the
dsk
scriptfor
loop could bring problems with%%parameter
variable; vetoed to use in a macro:%%{
(outer loop) and%%?
%%@
(inner loop)doskey a=dir ^> somefile
;^&
concatenated commands in a macro (but allowsdoskey
intrinsic$T
concatenation);.bat
or.cmd
scripts (needscall %xitem%
instead of%xitem%
in the:doItem
procedure (cca 50th line);The script
dsk
is as follows:With next scenario:
and
dsk y b a x n
call gives next output:The script is rather verbose for debugging purposes (and variable
CheckOnly
as well, with values1
= only echo commands,0
= echo and execute commands in a macro).