Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

help please - dos batch file

Thread Tools
 
Search this Thread
 
Old 15 October 2003, 03:37 PM
  #1  
Lisan Obelisk
Scooby Regular
Thread Starter
 
Lisan Obelisk's Avatar
 
Join Date: Oct 2003
Posts: 95
Likes: 0
Received 0 Likes on 0 Posts
Post

This works on Windows2000, supplying the variable with the correct day, but I now need it to work on WinXP and its not supplying the variable with a day. Instead the variable is filled with the full current date.


FOR /F "tokens=1" %%i in ('DATE /T') do set today=%%i

IF NOT "%today%"=="Mon" GOTO tuesday

(do something)

GOTO the_end

:tuesday
IF NOT "%today%"=="Tue" GOTO wednesday

(do something)

GOTO the_end

:wednesday

(do something)

:the_end


I'd really appreciate any help on solving this.
Old 15 October 2003, 10:46 PM
  #2  
DSOTM
Scooby Regular
 
DSOTM's Avatar
 
Join Date: Jul 2003
Posts: 75
Likes: 0
Received 0 Likes on 0 Posts
Post

XP doesn't display the date in that format by default.
Whent the batch file performs "date /t" it only gets back 15/10/2003 which is why its failing.

The only way I can find to solve it is to customise the English UK language setting.

Control Panel (Classic view)
Regional and Langauage Options
English (United Kingdom) -- "Customize" button
Date tab
Find the short date format and change it
from dd/MM/yyyy
to ddd dd/MM/yyyy
Apply and ok.

date /t now returns the same format as Win2K and your batch file will work.


Alternatively, do it in vbs. It's the future
Some pretty powerful stuff on Technet Script Center.
Old 16 October 2003, 09:39 AM
  #3  
Lisan Obelisk
Scooby Regular
Thread Starter
 
Lisan Obelisk's Avatar
 
Join Date: Oct 2003
Posts: 95
Likes: 0
Received 0 Likes on 0 Posts
Post

Thanks for that. I managed to get my hands on this code if its of any interest...


@echo off
if {%5}=={} @echo Syntax: Call day yyyy mm dd daynumb daytext&goto :EOF
setlocal
set montabl=0033614625035
set monleap=0623614625035
set daytab=7Sunday###1Monday###2Tuesday##3Wednesday4Th ursday#5Friday###6Saturday#
set /a century=1
set /a century4=1
set /a yyyy=%1
set /a mm=100%2%%100
set /a dd=100%3%%100
set /a leap=%yyyy%%%4
if %leap% EQU 0 set /a century=%yyyy%%%100
if %century% EQU 0 set /a century4=%yyyy%%%400
if %leap% EQU 0 set montabl=%monleap%
set /a day=%yyyy% + (%yyyy% / 4)
set /a day=%day% - (%yyyy% / 100)
set /a day=%day% + (%yyyy% / 400)
set /a day=%day% + %dd%
call set /a mon=%%montabl:~%mm%^,1%%
set /a day=%day% + %mon% - 1
set /a day=%day%%%7
set /a day=%day% * 10
if %century% EQU 0 if %century4% NEQ 0 if %mm% LSS 3 set daytab=1Monday###2Tuesday##3Wednesday4Thursday#5Fr iday###6Saturday#7Sunday###
call set w5=%%daytab:~%day%^,10%%
set /a daynumb=%w5:~0,1%
set daytext=%w5:~1,9%
set daytext=%daytext:#=%
endlocal&set %4=%daynumb%&set %5=%daytext%


useage: call filename.bat <year> <month> <day> var_daynum var_dayname

this code should be pretty much universal across all windows platforms, so no need to enter control panel, etc...

[Edited by Lisan Obelisk - 10/16/2003 3:43:18 PM]
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
blackieblob
ScoobyNet General
4
01 October 2015 11:37 AM
yabbadoo4
ScoobyNet General
11
30 September 2015 10:33 PM
Nick_Cat
Computer & Technology Related
2
26 September 2015 08:00 AM
Littleted
Computer & Technology Related
0
25 September 2015 08:44 AM



Quick Reply: help please - dos batch file



All times are GMT +1. The time now is 12:37 AM.