Labels: c++ (6) scripting (4) the perfect project (3) coding (1) firefox (1) idea (1)

Saturday, February 3, 2007

Touch for C++ h and cpp files

This is the batch file Touch.bat which I use for creating new files. When you create C++ source file it fills it with custom headers and includes. Pretty handy for adding new source files to Visual Studio projects. =)
@echo off
if exist %1 goto alreadyexist
goto nop >%1
if "%~x1"==".h" goto horcpp
if "%~x1"==".cpp" goto horcpp
goto :EOF

echo /** >>%1
echo * @file %1 >>%1
echo * >>%1
echo * @version \$Id: Exp $ >>%1
echo */ >>%1
if "%~x1"==".h" goto h
if "%~x1"==".cpp" goto cpp
echo Error, file is expected to be .h or .cpp on this point.
goto :EOF

echo #pragma once >>%1
goto :EOF

rem use ^> ^< to escape.
echo #include "StdAfx.h" >>%1
echo #include "%~n1.h" >>%1
goto :EOF

echo File %1 already exists, please delete it manually.
goto :EOF

No comments: