Reply
Old March 24th, 2006 Top | #1
 
dillinja's Avatar
OSNN Junior Addict
Joined: February 2006
Posts: 14
Reputation: 10
Power: 73

Default BATCH file help

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%

dillinja is offline   Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules

Similar Threads
Thread Thread Starter Forum Replies Last Post
vbscript or batch file to play audio file for user on startup Punkrulz Web Design & Coding 10 November 29th, 2006 2:48pm
Batch FIle PLEASE HELP arew264 Windows Desktop Systems 6 February 24th, 2005 1:56am
Batch File Q omg its nlm Web Design & Coding 4 March 10th, 2004 2:24am
Batch File Help the_tazinator Windows Desktop Systems 4 November 21st, 2003 1:12am
XP Batch file RogerPhillis Windows Desktop Systems 4 November 25th, 2002 12:18am