• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

BATCH file help


OSNN Junior Addict
This BATCH file works (I have only copied the upper part of the BATCH file), but only if there are 2 digits in the hour. If there is only one digit in the hour (eg 07:12) it fails because it puts a gap where the o' should be. How can I get the script to enter a two digit hour by default (eg '07') or alternatively handle the gap.

@echo off
for /F "usebackq tokens=1 delims=/ " %%i in ('%DATE%') do set day=%%i
for /F "usebackq tokens=2 delims=/ " %%i in ('%DATE%') do set month=%%i
for /F "usebackq tokens=3 delims=/ " %%i in ('%DATE%') do set year=%%i
for /F "usebackq tokens=1 delims=:" %%i in ('%TIME%') do set hour=%%i
for /F "usebackq tokens=2 delims=:" %%i in ('%TIME%') do set minute=%%i
set Date_Dir=%year%%month%%day%-%hour%%minute%

echo Exporting to %Date_Dir% direcory
if not exist %Date_Dir% mkdir %Date_Dir%

Members online

No members online now.

Latest posts

Latest profile posts

Hello, is there anybody in there? Just nod if you can hear me ...
What a long strange trip it's been. =)

Forum statistics

Latest member