• Current date in DOS script

    From Clinton@clinton@nospam.com to comp.os.ms-windows.misc on Thursday, August 07, 2003 16:09:49
    From Newsgroup: comp.os.ms-windows.misc

    I want to to run xcopy within a DOS script so that it always picks up the current month and year so that my backup only backs up files that have been created or amended since the first of the month. I've got a script that does this but I have to amend it each month to put a new date to xcopy in the /D parameter.

    XCOPY C:\MyStuff\*.* C:\MyStuffTemp /E /I /D:01-08-03 /Q

    Any ideas how I can code this so I don't have to amend it each month?

    Thanks
    Clinton


    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Phil Robyn@zipprobyn@uclink.berkeley.edu to comp.os.ms-windows.misc on Thursday, August 07, 2003 13:00:39
    From Newsgroup: comp.os.ms-windows.misc

    Clinton wrote:

    I want to to run xcopy within a DOS script so that it always picks up the current month and year so that my backup only backs up files that have been created or amended since the first of the month. I've got a script that does this but I have to amend it each month to put a new date to xcopy in the /D parameter.

    XCOPY C:\MyStuff\*.* C:\MyStuffTemp /E /I /D:01-08-03 /Q

    Any ideas how I can code this so I don't have to amend it each month?

    Thanks
    Clinton


    <Win2000> c:\cmd>demo\GetMonthandYear
    month is 08, year is 2003
    two-digit year is 03

    <Win2000> c:\cmd>rlist demo\GetMonthandYear.cmd
    =====begin c:\cmd\demo\GetMonthandYear.cmd ====================
    1. @echo off
    2. for /f "tokens=2,4 delims=/ " %%a in (
    3. 'date /t'
    4. ) do set month=%%a&set year=%%b
    5. echo month is %month%, year is %year%
    6. echo two-digit year is %year:~2%
    =====end c:\cmd\demo\GetMonthandYear.cmd ====================

    --
    Phil Robyn
    Univ. of California, Berkeley

    u n z i p m y a d d r e s s t o s e n d e - m a i l

    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Clinton@clinton@nospam.com to comp.os.ms-windows.misc on Friday, August 08, 2003 08:13:09
    From Newsgroup: comp.os.ms-windows.misc

    Thanks. I've pasted your code and run it but my output is:

    month is 08, year is
    two-digit year is ~2

    it seems as if the year is not being set.

    Thanks
    Clinton

    "Phil Robyn" <zipprobyn@uclink.berkeley.edu> wrote in message news:bgub69$stu1m$1@ID-55492.news.uni-berlin.de...
    Clinton wrote:

    I want to to run xcopy within a DOS script so that it always picks up
    the
    current month and year so that my backup only backs up files that have
    been
    created or amended since the first of the month. I've got a script that
    does
    this but I have to amend it each month to put a new date to xcopy in the
    /D
    parameter.

    XCOPY C:\MyStuff\*.* C:\MyStuffTemp /E /I /D:01-08-03 /Q

    Any ideas how I can code this so I don't have to amend it each month?

    Thanks
    Clinton


    <Win2000> c:\cmd>demo\GetMonthandYear
    month is 08, year is 2003
    two-digit year is 03

    <Win2000> c:\cmd>rlist demo\GetMonthandYear.cmd
    =====begin c:\cmd\demo\GetMonthandYear.cmd ====================
    1. @echo off
    2. for /f "tokens=2,4 delims=/ " %%a in (
    3. 'date /t'
    4. ) do set month=%%a&set year=%%b
    5. echo month is %month%, year is %year%
    6. echo two-digit year is %year:~2%
    =====end c:\cmd\demo\GetMonthandYear.cmd ====================

    --
    Phil Robyn
    Univ. of California, Berkeley

    u n z i p m y a d d r e s s t o s e n d e - m a i l



    --- Synchronet 3.18b-Win32 NewsLink 1.113