Created
February 3, 2016 09:25
-
-
Save ddikman/8cf9135e6397baab18fb to your computer and use it in GitHub Desktop.
Simple command line script for aliasing commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO off | |
IF "%1" == "" goto failUsage | |
WHERE alias.cmd > tmpPathFile | |
SET /p currdir= < tmpPathFile | |
del tmpPathFile | |
SET currdir=%currdir:alias.cmd=% | |
SET alias=%1 | |
SET targetName="%currdir%%alias%.cmd" | |
SET params= | |
:loop | |
SHIFT | |
IF _empty_%1 == _empty_ goto loopDone | |
SET params=%params% %1 | |
goto loop | |
:loopDone | |
SET params=%params:~1% | |
SET output=%params% %%* | |
Echo %output% > %targetName% | |
Echo Created alias: %alias% | |
Echo Alias will trigger: %params% | |
Echo Alias file is located next to alias.cmd: %targetName% | |
GOTO end | |
:failUsage | |
Echo Invalid arguments given, please use like this: | |
Echo alias ^<alias^> ^<file and arguments to alias^> | |
Echo. | |
Echo Example: alias rmdir_rec rmdir -r | |
Echo. | |
:end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment