Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: backup batch file to recognize day names  (Read 8510 times)

0 Members and 1 Guest are viewing this topic.

RonC

    Topic Starter


    Greenhorn

    • Experience: Beginner
    • OS: Windows 10
    Re: backup batch file to recognize day names
    « Reply #15 on: April 28, 2018, 10:19:37 AM »
    Sorry people, I may have screwed up and my celebration was premature. I tried the coding you suggested and it didn't work. Here is the code for my bat file:
    @echo off
    cd\
    cd\Users\RONALD\Desktop
    if /i "%dayname%"=="Monday" copy current*.* f:\monday /y
    if /i "%dayname%"=="Tuesday" copy current*.* f:\tuesday /y
    if /i "%dayname%"=="Wednesday" copy current*.* f:\wednesday /y
    if  /i"%dayname%"=="Thursday" copy current*.* f:\thursday /y
    if /i "%dayname% =="Friday" copy current*.* f:\friday /y
    if /i "%dayname% =="saturday" copy current.* f:\saturday /y

    When I run the bat file and then open the directory f:\saturday it is empty. Am I not properly identifying a variable? I can't figure it out.

    Thanks,

    RonC



    patio

    • Moderator


    • Genius
    • Maud' Dib
    • Thanked: 1769
      • Yes
    • Experience: Beginner
    • OS: Windows 7
    Re: backup batch file to recognize day names
    « Reply #16 on: April 28, 2018, 11:42:28 AM »
    Small S in Saturday ? ?
    " Anyone who goes to a psychiatrist should have his head examined. "

    RonC

      Topic Starter


      Greenhorn

      • Experience: Beginner
      • OS: Windows 10
      Re: backup batch file to recognize day names
      « Reply #17 on: April 28, 2018, 12:04:07 PM »
      No, that didn't do it. The directory I'm copying too is small s (saturday) and I've also tried it with the /I but it still didn't work.  The code below works fine:
      cd\
      cd\Users\RONALD\Desktop
      copy current*.* f:\saturday /y


      Thanks for the suggestion.

      RonC


      Salmon Trout

      • Guest
      Re: backup batch file to recognize day names
      « Reply #18 on: April 28, 2018, 12:23:34 PM »
      RonC, how does the batch script know what day it is? That is, how does the variable %dayname% get a value? I see nothing in your script that does that.


      Salmon Trout

      • Guest
      Re: backup batch file to recognize day names
      « Reply #19 on: April 28, 2018, 12:27:26 PM »
      Gone quiet...
      « Last Edit: April 28, 2018, 01:19:07 PM by Salmon Trout »

      Salmon Trout

      • Guest
      Re: backup batch file to recognize day names
      « Reply #20 on: April 28, 2018, 02:36:42 PM »
      If anyone is interested, this will do it...

      Code: [Select]
      @echo off
      echo wscript.echo weekdayname(weekday(now)) > "%temp%\wdn.vbs"
      for /f "delims=" %%A in ('cscript //nologo "%temp%\wdn.vbs"') do set dayname=%%A
      del "%temp%\wdn.vbs"
      REM this line is optional:
      echo Today is %dayname%
      Code: [Select]
      C:\Batch\Test>dayname.bat
      Today is Saturday



      Salmon Trout

      • Guest
      Re: backup batch file to recognize day names
      « Reply #21 on: April 28, 2018, 02:40:45 PM »
      The code below works fine:
      cd\
      cd\Users\RONALD\Desktop
      copy current*.* f:\saturday /y

      That's because it doesn't depend on the script knowing what day it is, which it will not be able to magically do.

      patio

      • Moderator


      • Genius
      • Maud' Dib
      • Thanked: 1769
        • Yes
      • Experience: Beginner
      • OS: Windows 7
      Re: backup batch file to recognize day names
      « Reply #22 on: April 28, 2018, 03:17:10 PM »
      What day is it ? ?.... :P
      " Anyone who goes to a psychiatrist should have his head examined. "

      RonC

        Topic Starter


        Greenhorn

        • Experience: Beginner
        • OS: Windows 10
        Re: backup batch file to recognize day names
        « Reply #23 on: April 28, 2018, 03:29:34 PM »
        Thanks guys. I'll give it a go and let you know.

        RonC

        Salmon Trout

        • Guest
        Re: backup batch file to recognize day names
        « Reply #24 on: April 28, 2018, 03:32:16 PM »
        How did you think the script was going to know the day of the week? Curious to know.

        RonC

          Topic Starter


          Greenhorn

          • Experience: Beginner
          • OS: Windows 10
          Re: backup batch file to recognize day names
          « Reply #25 on: April 28, 2018, 04:25:52 PM »
          Well guys, it worked for "Saturday". I'm going to set my alarm for 12:01am to verify that it works for "sunday".
           ;D

          Thanks,

          RonC

          Salmon Trout

          • Guest
          Re: backup batch file to recognize day names
          « Reply #26 on: April 28, 2018, 05:20:25 PM »
          How did you think the script was going to know the day of the week? Curious to know.

          RonC

            Topic Starter


            Greenhorn

            • Experience: Beginner
            • OS: Windows 10
            Re: backup batch file to recognize day names
            « Reply #27 on: April 29, 2018, 12:11:11 PM »
            Salmon Trout; the code you provided works perfectly. Thank you so much (and a big thank you to Patio and others for their comments also). Just so you know; I do volunteer work for the International Rescue Committee , a non-profit organization founded through the work of Albert Einstein, which responds to the world’s worst humanitarian crises and helps people whose lives and livelihoods are shattered by conflict and disaster to survive, recover, and gain control of their future. I'm retired and spend a lot of time writing small computer programs for them, primarily for administration support, using Microsoft Access. I use this and other forums for guidance and the availability and willingness of people like you all to provide that support has been a godsend.

            Thanks again.

            RonC

            patio

            • Moderator


            • Genius
            • Maud' Dib
            • Thanked: 1769
              • Yes
            • Experience: Beginner
            • OS: Windows 7
            Re: backup batch file to recognize day names
            « Reply #28 on: April 29, 2018, 02:33:28 PM »
            Thank You for volunteering...
            " Anyone who goes to a psychiatrist should have his head examined. "

            Salmon Trout

            • Guest
            Re: backup batch file to recognize day names
            « Reply #29 on: April 29, 2018, 03:30:06 PM »
            It's good to know that there are still people like that.