Skip to content

Instantly share code, notes, and snippets.

@thebirk
Last active February 7, 2020 21:29
Show Gist options
  • Save thebirk/c36dfcee5378fd39c70ae0aa510065c2 to your computer and use it in GitHub Desktop.
Save thebirk/c36dfcee5378fd39c70ae0aa510065c2 to your computer and use it in GitHub Desktop.
Copies any file into the folder in which 'install.bat' is located. Useful for copying files into a directory exposed through PATH
@echo off
REM Copyright 2020 Aleksander B. Birkeland <pingnor@gmail.com>
REM
REM Permission is hereby granted, free of charge, to any person obtaining a
REM copy of this software and associated documentation files (the "Software"),
REM to deal in the Software without restriction, including without limitation
REM the rights to use, copy, modify, merge, publish, distribute, sublicense,
REM and/or sell copies of the Software, and to permit persons to whom the
REM Software is furnished to do so, subject to the following conditions:
REM
REM The above copyright notice and this permission notice shall be included in
REM all copies or substantial portions of the Software.
REM
REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
REM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
REM FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
REM AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
REM LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
REM FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
REM DEALINGS IN THE SOFTWARE.
setlocal
set argc=0
for %%x in (%*) do Set /A argc+=1
if %argc% EQU 1 (
1<nul copy /Y %~f1 %~dp0
echo Installed %~nx1
) else (
echo|set /p="Usage: %~nx0 <file>"
exit /B 1
)
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment