BATCH file help

dillinja

OSNN Junior Addict
Joined
19 Feb 2006
Messages
14
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 profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back