Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

help with batchfile running on certain days

Featured Replies

Hi all,

anyone help me on this i want on certain days to run diffrent .bat files I have this but its not working... Im sorry im new to creating batch files anyone help me???

@ECHO OFF

:LOOP

ECHO Waiting for 5 minutes...

PING -n 300 127.0.0.1>nul

IF %DATE:~0,3%==Mon CALL monbreakfast-rename.bat

IF %DATE:~0,3%==Tue CALL tuesbreakfast-rename.bat

IF %DATE:~0,3%==Wed CALL wedbreakfast-rename.bat

IF %DATE:~0,3%==Thu CALL thursbreakfast-rename.bat

IF %DATE:~0,3%==Fri CALL fribreakfast-rename.bat

IF %DATE:~0,3%==Sat CALL satbreakfast-rename.bat

IF %DATE:~0,3%==Sun CALL sunbreakfast-rename.bat

Can you post the output of (in a command window)

ECHO %DATE%

[ENTER]

Then post the output of

DATE

[ENTER]

and

DATE /T

[ENTER]

and

Echo.|Command /C Date

[ENTER]

? :unsure:

AND read this :

http://www.robvanderwoude.com/datetime.php

(and pages linked to, expecially these):

http://www.robvanderwoude.com/datetimentmath.php

before posting the said info. ;)

Which OS are you running?

Check these, too ;):

http://support.mogware.net/index.php?topic=930.0

http://www.computing.net/answers/windows-x...eek/152202.html

jaclaz

Edited by jaclaz

my output on date is

Current date is Mon 11/01/2010

how can i parse mon in dos??

It's really DOS?

Or is it Command Prompt of a NT based system?

Like 2K, XP or Vista or 7?

The answer is however already in the given links, have you checked them (hint: last one may do if not "pure" DOS ;))

jaclaz

  • Author

ok ignore that, im on xp and i cant work out how to get the date command to show me todays Day so i can parse it.

@For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @(

set Day=%%a

set month=%%b

Set year=%%C

)

if %DAY%==Mon goto :mon

if %DAY%==Tue goto :tue

if %DAY%==Wed goto :wed

if %DAY%==Thu goto :thu

if %DAY%==Fri goto :fri

if %DAY%==Sat goto :sat

if %DAY%==Sun goto :sun

Now i know the date /t command dont show the day (mon) but doing Echo.|Command /C Date

does show at day(mon) how can i parse that command?

Sorry for being a noob I am learning, takes some time

If you wanted to try a vbs script, I have it so echo out the day Name.

This could be modified to do what you want it to.

Dim MyDate :MyDate = WeekdayName(Weekday(Now))
Select Case MyDate
Case "Monday"
WScript.Echo "Today Is : " & MyDate
Case "Tuesday"
WScript.Echo "Today Is : " & MyDate
Case "Wednesday"
WScript.Echo "Today Is : " & MyDate
Case "Thursday"
WScript.Echo "Today Is : " & MyDate
Case "Friday"
WScript.Echo "Today Is : " & MyDate
Case "Saturday"
WScript.Echo "Today Is : " & MyDate
Case "Sunday"
WScript.Echo "Today Is : " & MyDate
End Select

Here is what you wanted a way to run bat on certain days

Save as RunBat.vbs

 Dim Act :Set Act = CreateObject("Wscript.Shell")
Dim MyDate :MyDate = WeekdayName(Weekday(Now))
Select Case MyDate
Case "Monday"
Act.Run("Cmd /C monbreakfast-rename.bat"),1,True
Case "Tuesday"
Act.Run("Cmd /C tuesbreakfast-rename.bat"),1,True
Case "Wednesday"
Act.Run("Cmd /C wedbreakfast-rename.bat"),1,True
Case "Thursday"
Act.Run("Cmd /C thursbreakfast-rename.bat"),1,True
Case "Friday"
Act.Run("Cmd /C fribreakfast-rename.bat"),1,True
Case "Saturday"
Act.Run("Cmd /C satbreakfast-rename.bat"),1,True
Case "Sunday"
Act.Run("Cmd /C sunbreakfast-rename.bat"),1,True
End Select

This one I added a check to make sure the file exists before it ran

Save As RunBatch.vbs

 Dim Act :Set Act = CreateObject("Wscript.Shell")
Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim MyDate :MyDate = WeekdayName(Weekday(Now))
Dim CmdRun
Select Case MyDate
Case "Monday" : CmdRun = "monbreakfast"
Case "Tuesday" : CmdRun = "tuesbreakfast"
Case "Wednesday" : CmdRun = "wedbreakfast"
Case "Thursday" : CmdRun = "thursbreakfast"
Case "Friday" : CmdRun = "fribreakfast"
Case "Saturday" : CmdRun = "satbreakfastt"
Case "Sunday" : CmdRun = "sunbreakfast"
End Select
CmdRun = Act.CurrentDirectory & "\" & CmdRun & "-rename.bat"
If Fso.FileExists(CmdRun) Then
Act.Run("Cmd /C " & Chr(34) & CmdRun & Chr(34)),1,True
Else
MsgBox "ERROR : Can Not Find This File" & vbCrLf & CmdRun,4128,"Missing File Error"
End If

Now i know the date /t command dont show the day (mon) but doing Echo.|Command /C Date

does show at day(mon) how can i parse that command?

Sorry for being a noob I am learning, takes some time

Well, the parsing approach with a FOR seems allright to me.

What happens if on Command Line, NOT in a batch you issue:

FOR /F "tokens=4" %A IN ('Echo.^|Command /C Date') DO ECHO %A

(you should be able to copy and paste the above on command line.

If you get the "mon" (BTW:you know your clock/calendar is 4 days late, don't you?)

Try this:

@FOR /F "tokens=1,4" %A IN ('Echo.^|Command /C Date') DO @IF %A.==Current. SET %A=%B&SET %A

Read how for tokens/delimiters work:

http://www.robvanderwoude.com/ntfortokens.php

:hello:

jaclaz

To try to help you with the parsing, as already requested by jaclaz, we really do need to see some output.

For example, what is echo'd to the screen if you enter this at the 'command prompt'?

For %# In ("%Date%") Do @Echo/[%~#]

As a side note, you could use WMIC in a batch file.

@Echo off & Setlocal
Set "_=mon tues wed thurs fri sat sun"
For /f %%# In ('WMIC Path Win32_LocalTime Get DayOfWeek^|Findstr [1-7]') Do (
Set DOW=%%#)
For /f "tokens=%DOW%" %%# In ("%_%") Do Call %%#breakfast-rename.bat

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.