This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableDelayedExpansion | |
call :createSub | |
call :echoWithoutLinefeed "=hello" | |
call :echoWithoutLinefeed " world" | |
exit /b | |
:echoWithoutLinefeed | |
> txt.tmp (echo(%~1!sub!) | |
copy txt.tmp /a txt2.tmp /b > nul |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableExtensions DisableDelayedExpansion | |
:: Find and Replace [Works with Special Characters] | |
:: by David Ruhmann | |
:: About | |
:: This is a proof of concept to illustrate the difficulty and limitations in | |
:: regards to the batch string replacement functionality. Delayed Expansion was | |
:: not used as an exercise in showing the most common usage of batch. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableExtensions | |
for %%A in (*.url) do ( | |
for /f "usebackq tokens=1,* delims==" %%X in ("%%~fA") do ( | |
if /i "%%X"=="Url" ( | |
echo(%%~nA = %%Y>>list.txt | |
echo(%%Y | |
) | |
) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableDelayedExpansion | |
if "%~1"==":::" goto :spinnerThread | |
:menuLoop | |
<nul set /p menu=Select menu[1 or 2]= | |
call :GetKey | |
echo( | |
echo Pressed '!key!' | |
if !key!==1 call :menu1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableExtensions EnableDelayedExpansion | |
:: Setup | |
set "ResultsFolder=results" | |
set "ExportFile=output.txt" | |
:: Verify that the Results folder exists | |
if not exist "%ResultsFolder%\*" md "%ResultsFolder%" | |
set "OutputFile=%ResultsFolder%\%ExportFile%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CMD processes redirection from left to right. You want to first redirect 2 (stderr) to &1 (stdout), then redirect 1 (stdout) to something else. At this point stderr will still be redirected to the previous definition of stdout. The pipe will still work with the old definition of stdout (which now contains stderr). | |
If you don't care about stdout then you can redirect to nul | |
program.exe 2>&1 1>nul | find " " | |
If you want to capture stdout to a file then redirect to a file | |
program.exe 2>&1 1>yourFile | find " " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Echo Off | |
Call :Color A "######" \n E "" C " 21 " E "!" \n B "######" \n | |
Pause >Nul | |
Exit /B | |
:Color | |
:: v21 | |
:: Arguments: hexColor text [\n] ... | |
:: \n -> newline ... -> repeat | |
:: Supported in windows XP, 7, 8. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2015 David Ruhmann | |
using System; | |
using System.ComponentModel; | |
using System.Linq; | |
using System.Text; | |
using System.Collections.Generic; | |
namespace ChartedCode | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@if (@CodeSection == @Batch) @then | |
:: The first line above is... | |
:: in Batch, a valid IF command that does nothing. | |
:: in JScript, a conditional compilation IF statement that is false. | |
:: So the following section is omitted until the next "[at]end". | |
:: Note: the "[at]then" does nothing and is only for readablility. | |
:: Batch Section |