1

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.

Govind Parmar
  • 20,656
  • 7
  • 53
  • 85

1 Answers1

1

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.

Govind Parmar
  • 20,656
  • 7
  • 53
  • 85
  • Seems to just open the link repeatedly, forever – Clarence Hog Mar 05 '19 at 20:44
  • What exactly does `openlink` do when called standalone on the command line? – Govind Parmar Mar 05 '19 at 20:45
  • Sorry, probably "start chrome (link)" "start chrome" by its self just opens a new tab in chrome – Clarence Hog Mar 05 '19 at 20:47
  • @ClarenceHog If you have found that my answer has solved your problem, you are welcome to [mark it as accepted](https://stackoverflow.com/help/someone-answers) – Govind Parmar Mar 05 '19 at 20:55
  • Another questions if that is ok. Is it possible to run this as a command, like `video 3` using doskey? – Clarence Hog Mar 05 '19 at 21:03
  • @ClarenceHog Not entirely sure what you're asking there. – Govind Parmar Mar 05 '19 at 21:04
  • So `doskey` can be used to set a custom command. eg `doskey openyt=start chrome www.youtube.com` then if you ran `openyt` it would open up youtube. I would like that but have the post-fix on the end to open it up `x` many times. Eg `openyt 4` which would open youtube 4 times – Clarence Hog Mar 05 '19 at 21:06
  • @ClarenceHog As far as I'm aware, there isn't that functionality in doskey, hence why I proposed a solution of creating a batch file; just put it somewhere in your system's `%path%` and name it `openyt.bat` rather than creating a doskey macro and there will be no observable difference to you. – Govind Parmar Mar 05 '19 at 21:10