User Tools

Site Tools


batchfiles

Batch Files

No spaces around assignment statements.

set x=2 ok.
set x = 2 will not work.

This batch file looks for x86 or x64

@echo off
IF "%1"=="" GOTO bad
IF "%1"=="x86" GOTO ok
IF "%1"=="x64" GOTO ok
:bad 
echo "parameter must be x86 or x64"
goto end
:ok
echo using %1%
:end

This batch file get the date and time in yyyy-mm-dd-hh-mm format

echo off
echo %date%
set year=%date:~10,4%
set month=%date:~4,2%
IF "%MONTH:~0,1%" == " " SET MONTH=0%MONTH:~1,1%
set day=%date:~7,2%
IF "%DAY:~0,1%" == " " SET DAY=0%DAY:~1,1%
echo %time%
set hour=%time:~0,2%
IF "%HOUR:~0,1%" == " " SET HOUR=0%HOUR:~1,1%
set minute=%time:~3,2%
IF "%Minute:~0,1%" == " " SET Minute=0%Minute:~1,1%
set ts=%year%-%month%-%day%_%hour%-%minute%
echo %ts%

Sample usage

sqlplus jwars/password@jas @createJwarsTableCreationSql.sql > createJwarsTableCreationSql%ts%.log
batchfiles.txt · Last modified: 2024/06/10 11:40 by 127.0.0.1