@echo off
rem ------------------------------------------------------------------------------
rem ideas.bat has some Windows Batch file ideas
rem ------------------------------------------------------------------------------
rem ------------------------------------------------------------------------------
rem Way to check if first parameter defined and an existant file
rem ------------------------------------------------------------------------------
@if %1TRICK==TRICK goto preprebit2
@if not exist %1 goto prebit2
rem ------------------------------------------------------------------------------
rem use for to type out first four words of lines of file, separated by then
rem ------------------------------------------------------------------------------
echo.
echo.
@for /F "usebackq tokens=1,2,3,4* delims= " %%e IN ("%1") DO @echo %%e *then* %%f *then* %%g *then* %%h
rem ------------------------------------------------------------------------------
rem Way to prompt for delimiter, for instance
rem ------------------------------------------------------------------------------
echo.
echo.
set /p d=What is your word delimiter (the report above was for space as delimiter) for first three words of lines of %1 (shown in reports above and below separated by *then*)?
cls
@for /F "usebackq tokens=1,2,3,4* delims=%d%" %%e IN ("%1") DO @echo %%e *then* %%f *then* %%g *then* %%h
echo.
echo.
pause
rem ------------------------------------------------------------------------------
rem Show current date and time
rem ------------------------------------------------------------------------------
cls
echo.
echo.
echo.
echo.
echo. > %TEMP%/in.in
date < %TEMP%/in.in                                                                                                   a
time < %TEMP%/in.in
rem ------------------------------------------------------------------------------
rem Some maths
rem ------------------------------------------------------------------------------
set /a "_num=5+6"
echo %_num% = 5 + 6
set /A "_num=34"
set /A "_num*=67"
echo %_num% = 34 * 67
set /A "_num=65%%17"
echo %_num% = remainder of 65 divided by 17
rem ------------------------------------------------------------------------------
rem Some date parsing ... thanks to http://www.tech-recipes.com/rx/956/windows-batch-file-bat-to-get-current-date-in-mmddyyyy-format/
rem ------------------------------------------------------------------------------
@for /F "usebackq TOKENS=1* DELIMS= " %%A IN (`DATE/T`) DO SET CDATE=%%B
@for /F "usebackq TOKENS=1,2 eol=/ DELIMS=/ " %%A IN (`DATE/T`) DO SET mm=%%B
@for /F "usebackq TOKENS=1,2 DELIMS=/ eol=/" %%A IN (`echo %CDATE%`) DO SET dd=%%B
@for /F "usebackq TOKENS=2,3 DELIMS=/ " %%A IN (`echo %CDATE%`) DO SET yyyy=%%B
echo Today's date is made up of month %mm% and day %dd% and year %yyyy% 
rem ------------------------------------------------------------------------------
rem Show a substring
rem ------------------------------------------------------------------------------
echo.
echo.
set ipos=12
set jpos=8
set sentence=There is an elephant in the room
call set substr=%%sentence:~%ipos%,%jpos%%%
echo (%substr%) is substring from (%ipos%+1) for %jpos% of %sentence%
rem ------------------------------------------------------------------------------
rem Choose between three options but default to one after 5 seconds
rem Show current date and time
rem ------------------------------------------------------------------------------
echo.
echo.
echo.
echo.
echo. > %TEMP%/in.in
date < %TEMP%/in.in
time < %TEMP%/in.in
choice /c:ync /t:5 /d n /m "Press Y or N or [C] (5 seconds)"
rem ------------------------------------------------------------------------------
rem Show current date and time
rem ------------------------------------------------------------------------------
echo. > %TEMP%/in.in
date < %TEMP%/in.in
time < %TEMP%/in.in
rem ------------------------------------------------------------------------------
rem Wait 12 seconds via ping
rem ------------------------------------------------------------------------------
echo.
echo ping is waiting approximately 12 seconds
ping -n 12 127.0.0.1 > nul
rem ------------------------------------------------------------------------------
rem Show current date and time
rem ------------------------------------------------------------------------------
echo. > %TEMP%/in.in
date < %TEMP%/in.in
time < %TEMP%/in.in
goto bit2
:preprebit2
echo %0 a-real-file.name was expected
goto bit2
:prebit2
echo %1 not an existant file
:bit2
rem ------------------------------------------------------------------------------
rem Show systeminfo information
rem ------------------------------------------------------------------------------
echo.
echo.
echo.
echo.
echo Showing systeminfo information below ... please wait ...
systeminfo
rem exit