Search code examples
batch-filecmddoskey

How to add a post-fix to a DOSKEY [CMD]


I would like a prefix to run a command but slightly differently, for example

openlink (opens the link)

Then I would like to be able to say open it 2 times by using a prefix, for example

openlink *2 (opens the link twice)

I would like the number to be corresponding to the times opened Eg. openlink *7 would open the link 7 times.


Solution

  • How about wrapping your command (openlink) in a batch file that uses set /A to keep track of a count?

    @echo off
    SET /A CNT=%1
    :l0
        openlink foo
        SET /A CNT=%cnt%-1
        IF NOT %cnt% == 0 GOTO l0
    :end
    

    Then, you could call it like myopenlink.bat N to call the command openlink foo N times.