\
Tips and Tricks
Batch Files
Batch File Tips and Tricks
Special Characters (tabs etc)
Special Characters (tabs etc) |
The following is a relatively simple way of using tabs or other
characters within a batch file without the need for some other
preinstalled "helper" program:
@echo off
setlocal
call :SetChar BEEP 7
call :SetChar TAB 9
set TabFile=NumberOfDumps@%date:/=-% %time::=_%.tab.txt
echo Column 1%TAB%Column 2%TAB%Column 3 > "%TabFile%
...
echo echo Beep!%BEEP%
goto :EOF
@REM **************[v08.178]******************
:SetChar
@REM *****************************************
set VbsFile=%TEMP%\SetChar-%random%.vbs
set CmdFile=%TEMP%\SetChar-%random%.cmd
echo if Wscript.Arguments.Count ^<^> 2 then > "%VbsFile%"
echo wscript.echo "REM Invalid parameters, expected 2 (1=EnvVar 2=AsciiCode), got " ^& Wscript.Arguments.Count >> "%VbsFile%"
echo else >> "%VbsFile%"
echo wscript.echo "@echo off" >> "%VbsFile%"
echo wscript.echo "SET " ^& Wscript.Arguments(0) ^& "=" ^& chr(Wscript.Arguments(1)) >> "%VbsFile%"
echo end if >> "%VbsFile%"
cscript.exe //NoLogo "%VbsFile%" "%~1" "%~2" > "%CmdFile%"
call "%CmdFile%"
del "%VbsFile%" >nul 2>&1
del "%CmdFile%" >nul 2>&1
goto :EOF
See the "VBSCRIPT subroutines in BATCH files"
section for more information on how this works.