1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development Old Skool - DOS Batch Scripting Help

Discussion in 'Software' started by JonDixon, 27 Feb 2006.

  1. JonDixon

    JonDixon Decking is the new modding

    Joined:
    12 Mar 2002
    Posts:
    696
    Likes Received:
    0
    Hi all,

    In need of a little help again. I have 2 already developed scripts daily.bat and weekly.bat

    I am struggling to write a script which will do the following:

    IF day NOT IN ('Saturday', 'Sunday') THEN
    Run daily.bat
    ELSIF day = 'Saturday' THEN
    Run daily.bat
    Run weekly.bat
    ENDIF
    EXIT

    Any help on how I do this in DOS batch script appreciated.

    Cheers
     
  2. FuzzyOne

    FuzzyOne

    Joined:
    19 Sep 2002
    Posts:
    1,839
    Likes Received:
    37
    Download http://ww2.netnitco.net/users/cruth/cutpak13.zip you want DAYOFWK.COM from the archive.

    Create a new batch file, backup.bat or whatever ...

    all simple and should get the job done
     
  3. FuzzyOne

    FuzzyOne

    Joined:
    19 Sep 2002
    Posts:
    1,839
    Likes Received:
    37
    I should add the script is not missing "if errorlevel 1 goto Sunday", this is always left as a last resort
     
  4. JonDixon

    JonDixon Decking is the new modding

    Joined:
    12 Mar 2002
    Posts:
    696
    Likes Received:
    0
    Cheers for that, that is exactly what I need.

    Thanks
     
  5. DosItHelp

    DosItHelp What's a Dremel?

    Joined:
    2 Mar 2006
    Posts:
    1
    Likes Received:
    0
    In WinXP and some help from http://dostips.cmdtips.com/DtTipsStringManipulation.php I figured you can do the following:

    Code:
    @ECHO OFF
    REM.-- Prepare the Command Processor
    SETLOCAL ENABLEEXTENSIONS
    SETLOCAL ENABLEDELAYEDEXPANSION
    
    set daily=,Mon,Tue,Wed,Thu,Fri,Sat,
    set weekly=,Sun,
    
    REM.-- Extract the day into %day%
    for /f %%a in ("%date%") do set day=%%a
    
    if "!daily:%day%=!" NEQ "!daily!" echo run daily.bat
    if "!weekly:%day%=!" NEQ "!weekly!" echo run weekly.bat
    Enjoy :thumb:
     

Share This Page