Tag Archives: batch

Set an environment variable to the current working directory

The current directory is in the “shadow” variable cd called var. set “var=%cd%” set var

Posted in develop | Tagged , | Leave a comment

MSDOS Error checking

How to nicely do an error checking in MSDOS? IF %LOG_FLAG% == YES CALL %GMAKE_HOME%\gmake -f makefile.tdp > ..\logfiles\sql-winx32_bld.log 2>&1 CALL SET COMPILERESULT=%errorlevel% @if %COMPILERESULT% NEQ 0 ( @echo SQL x32 Compiling failed. exit /B %COMPILERESULT% ) IF %LOG_FLAG% == … Continue reading

Posted in develop | Tagged , , , | Leave a comment

Use sed on Windows to add new XML tags

To add versions tags in vcxproj and csproj files in a project you can use three batch scripts. 1) change_csproj.bat :: Script to add new TSM version tags into csproj files :: Get ONLY the files that contains TSMVERSION tag, … Continue reading

Posted in develop | Tagged , , , , | Leave a comment

Logical operators (“and”, “or”) in DOS batch

You can do and with nested conditions: if %age% geq 2 ( if %age% leq 12 ( set class=child ) ) or: if %age% geq 2 if %age% leq 12 set class=child You can do or with a separate variable: … Continue reading

Posted in Uncategorized | Tagged , | Leave a comment

Use sed to edit xml file

General usage of GNU sed on Windows sed -i -e “s|what|replacewith|g” file -i replaces the original file -e runs expression s|what|replacewith|g replaces all / globally what occurrences with replacewith You can avoid g if you want to stop at the … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

MSDOS operators for multiple commands

MSDOS operators for multiple commands Command A & Command B Execute Command A, then execute Command B (no evaluation of anything) Command A | Command B Execute Command A, and redirect all its output into the input of Command B … Continue reading

Posted in Uncategorized | Tagged , , , , | Leave a comment

How to list all files that does not contain a pattern (i.e. string) ?

How to list all files that does not contain a pattern? LIST all csproj files that does not contain certain string (i.e. BUILD_TSM_VERSION) @for /r %f in (*.csproj) do @find “BUILD_TSM_VERSION” “%f” > nul || echo %f @for /r %f … Continue reading

Posted in Uncategorized | Tagged , | Leave a comment