Skip to content

Instantly share code, notes, and snippets.

@teamaton
Created July 15, 2011 06:58
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 teamaton/1084221 to your computer and use it in GitHub Desktop.
Save teamaton/1084221 to your computer and use it in GitHub Desktop.
Zipping and copying a VS multi-file item template
@echo off
:echo %~p0
REM
REM retrieve the name of the last folder in the path
REM
SET mydir=%~p0
SET mydir=%mydir:\= %
for %%a in (%mydir%) do set LastFolder=%%~nxa
:echo %LastFolder%
set zipexe="C:\Program Files\7-zip\7z.exe"
IF NOT EXIST %zipexe% (
echo.
echo ERROR: The 7-zip exe could not be found at the above location.
goto :ERROR
)
del %LastFolder%.zip
call %zipexe% a %LastFolder%.zip *.cs *.vstemplate
REM
REM Destination folder is the VS custom item template folder
REM
set destination="%UserProfile%\My Documents\Visual Studio 2010\Templates\ItemTemplates\Visual C#\Code"
IF NOT EXIST %destination% (
echo.
echo ERROR: The destination folder could not be found at the above location.
goto :ERROR
)
copy %LastFolder%.zip %destination%
echo.
echo Successfully copied %LastFolder%.zip to %destination%.
echo.
pause
goto :eof
:ERROR
echo.
echo # An error occurred - the template was not copied to the destination. #
echo.
pause
@echo on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment