Computing.Net > Forums > Windows XP > Batch file to calculate day of week

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file to calculate day of week

Reply to Message Icon

Name: shadow
Date: June 7, 2006 at 01:40:19 Pacific
OS: Windows XP Pro
CPU/Ram: N/A
Product: N/A
Comment:

Hi, I wonder if you can help me please - I need to write a .BAT file to perform a given action on a given day each week, so for example, if today is a Wednesday, then engage this command (the command could be anything, and it's not that which I'm interested in).

How do I write ... in a .BAT file (to run under Windows XP Pro) ... a command that will calculate the day of the week please ?

I HAD a .BAT file that worked on Windows 2000, the text of which was like this :-

@ECHO OFF
@For /F "tokens=1,2,3 delims=. " %%A in ('Date /t') do @(
Set Day=%%A
)

IF %day%==Mon goto :URLSMONDAY
IF %day%==Tue goto :URLSTUESDAY
IF %day%==Wed goto :URLSWEDNESDAY
IF %day%==Thu goto :URLSTHURSDAY
IF %day%==Fri goto :URLSFRIDAY
EXIT
END


:URLSMONDAY
monday.html

EXIT

:URLSTUESDAY
monday.html

EXIT

:URLSWEDNESDAY
monday.html

EXIT

:URLSTHURSDAY
monday.html

EXIT

:URLSFRIDAY
friday.html

EXIT

Basically I used this to call up a list of internet sites I needed to visit on given days - e.g. Monday I need to check my bank balance, Tuesday I need to visit a forum, Wednesday something else, etc., etc. I automate the .BAT file to run at 7am using the Task Scheduler, so by the time I get to work all the pages are waiting for me ...

Cheers guys,

David.



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: June 7, 2006 at 02:13:28 Pacific
Reply:

An annoying difference betwen Win 2K and XP is the lack in XP of the Day of Week in the Date command. To work around that you can parse the output of

Echo.|Command /C Date

that forces the legacy DOS format including Day of Week. I can adjust your batch, but I need you report *exactly* what is displayed by the above command as I'm running an italian version of XP and to parse the text I need to know it as is.


0

Response Number 2
Name: Mechanix2Go
Date: June 7, 2006 at 03:35:54 Pacific
Reply:

"An annoying difference betwen Win 2K and XP"

Yeah, one of many.


If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Batch file to calculate day of week

Batch file to delete files +60 days www.computing.net/answers/windows-xp/batch-file-to-delete-files-60-days/149698.html

Batch file to capture ping response times www.computing.net/answers/windows-xp/batch-file-to-capture-ping-response-times/179253.html

Batch file to delete by date www.computing.net/answers/windows-xp/batch-file-to-delete-by-date-/135330.html