Skip to content

Instantly share code, notes, and snippets.

@ddikman
Created February 3, 2016 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddikman/8cf9135e6397baab18fb to your computer and use it in GitHub Desktop.
Save ddikman/8cf9135e6397baab18fb to your computer and use it in GitHub Desktop.
Simple command line script for aliasing commands
@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