Source:http://jpsoft.com/help/index.htm?alias.htm
Aliases can use command line
parameters or parameters like those in
batch files. The command line
parameters are numbered from %0 to
%511. (%0 contains the alias name.)For example, the following alias will
change directories, perform a command,
and return to the original directory:alias in
pushd %1 & %2$ & popd
when i run the above, my command prompt gives error saying
%1 * Unable to read value of alias *
‘%2’ is not recognized as an internal or external command,
operable program or batch file.
‘popd`’ is not recognized as an internal or external command,
operable program or batch file.
if you use double quote instead, alias in “pushd %1 & dir & popd”
it doesn’t interprets the %1 when you execute the alias
C:\abc\def>alias
Dumping all defined aliases for CMD.EXE.
in =pushd %1 & dir & popd
alias def wont work
———EDIT————
let me try some sample output with a simple echo alias
D:\abc\def>alias /?
Usage: ALIAS [-v] [-p programName] [-f filespec] [ ]
[-v] means verbose output.
[-d] means delete aliases.
[-p programName] specifies which image file name these alias
definitions are for. Default is CMD.EXE
[-f filespec] specifies a file which contains the alises.
C:\Office\dev15>alias out ‘echo %1’
%1′ * Unable to read value of alias *
C:\Office\dev15>alias out backtick echo %1 backtick
%1` * Unable to read value of alias *
C:\Office\dev15>alias out “echo %1”
C:\Office\dev15>alias
Dumping all defined aliases for CMD.EXE.
out =echo %1
C:\Office\dev15>out abc
%1
C:\Office\dev15>alias out echo %1
%1 * Unable to read value of alias *
C:\Office\dev15>out abc
ECHO is on.
Problem is,
both single quote and back tick produces error,
while double quote wont treat %1 as variable parameter
also tried with none of the quotes.
still wouldnot work
Okay, try this (use copy and paste):
This sets the alias ‘dtxt‘ to the following commands:
Pay particular attention to the inverted single quotes (`) around the alias definition. This is found on the top-left key on the ISO (UK) and ANSI (US) keyboards.
You will need to supply two parameters, %1 and %2 when executing dtxt – a target pathname, and a parameter for the DIR command as in the following examples:
In a nutshell, PUSHD pushes the current working directory name onto a LIFO stack and changes directory to c:\temp.
The DIR command then executes with %2 as it’s parameter – in this case ‘*.txt‘.
Finally, POPD restores the previous working directory by popping it off the stack.
FYI, this is equivalent to the following standard DOS command:
The following command in standard DOS will also work fine:
But obviously, ‘dtxt‘ is shorter and saves keystrokes!